कंसोल पर जाएं

firebase_admin.messaging module

Firebase Cloud Messaging module.

Exceptions

exception firebase_admin.messaging.ApiCallError(code, message, detail=None)

Bases: exceptions.Exception

Represents an Exception encountered while invoking the FCM API.

code

A string error code.

message

A error message string.

detail

Original low-level exception.

Classes

class firebase_admin.messaging.AndroidConfig(collapse_key=None, priority=None, ttl=None, restricted_package_name=None, data=None, notification=None, fcm_options=None)

Bases: object

Android-specific options that can be included in a message.

Parameters:
  • collapse_key – Collapse key string for the message (optional). This is an identifier for a group of messages that can be collapsed, so that only the last message is sent when delivery can be resumed. A maximum of 4 different collapse keys may be active at a given time.
  • priority – Priority of the message (optional). Must be one of high or normal.
  • ttl – The time-to-live duration of the message (optional). This can be specified as a numeric seconds value or a datetime.timedelta instance.
  • restricted_package_name – The package name of the application where the registration tokens must match in order to receive the message (optional).
  • data – A dictionary of data fields (optional). All keys and values in the dictionary must be strings. When specified, overrides any data fields set via Message.data.
  • notification – A messaging.AndroidNotification to be included in the message (optional).
  • fcm_options – A messaging.AndroidFCMOptions to be included in the message (optional).
class firebase_admin.messaging.AndroidFCMOptions(analytics_label=None)

Bases: object

Options for features provided by the FCM SDK for Android.

Parameters:analytics_label – contains additional options for features provided by the FCM Android SDK (optional).
class firebase_admin.messaging.AndroidNotification(title=None, body=None, icon=None, color=None, sound=None, tag=None, click_action=None, body_loc_key=None, body_loc_args=None, title_loc_key=None, title_loc_args=None, channel_id=None)

Bases: object

Android-specific notification parameters.

Parameters:
  • title – Title of the notification (optional). If specified, overrides the title set via messaging.Notification.
  • body – Body of the notification (optional). If specified, overrides the body set via messaging.Notification.
  • icon – Icon of the notification (optional).
  • color – Color of the notification icon expressed in #rrggbb form (optional).
  • sound – Sound to be played when the device receives the notification (optional). This is usually the file name of the sound resource.
  • tag – Tag of the notification (optional). This is an identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification.
  • click_action – The action associated with a user click on the notification (optional). If specified, an activity with a matching intent filter is launched when a user clicks on the notification.
  • body_loc_key – Key of the body string in the app’s string resources to use to localize the body text (optional).
  • body_loc_args – A list of resource keys that will be used in place of the format specifiers in body_loc_key (optional).
  • title_loc_key – Key of the title string in the app’s string resources to use to localize the title text (optional).
  • title_loc_args – A list of resource keys that will be used in place of the format specifiers in title_loc_key (optional).
  • channel_id – channel_id of the notification (optional).
class firebase_admin.messaging.APNSConfig(headers=None, payload=None, fcm_options=None)

Bases: object

APNS-specific options that can be included in a message.

Refer to APNS Documentation for more information.

Parameters:
  • headers – A dictionary of headers (optional).
  • payload – A messaging.APNSPayload to be included in the message (optional).
  • fcm_options – A messaging.APNSFCMOptions instance to be included in the message (optional).
class firebase_admin.messaging.APNSFCMOptions(analytics_label=None)

Bases: object

Options for features provided by the FCM SDK for iOS.

Parameters:analytics_label – contains additional options for features provided by the FCM iOS SDK (optional).
class firebase_admin.messaging.APNSPayload(aps, **kwargs)

Bases: object

Payload of an APNS message.

Parameters:
  • aps – A messaging.Aps instance to be included in the payload.
  • kwargs – Arbitrary keyword arguments to be included as custom fields in the payload (optional).
class firebase_admin.messaging.Aps(alert=None, badge=None, sound=None, content_available=None, category=None, thread_id=None, mutable_content=None, custom_data=None)

Bases: object

Aps dictionary to be included in an APNS payload.

Parameters:
  • alert – A string or a messaging.ApsAlert instance (optional).
  • badge – A number representing the badge to be displayed with the message (optional).
  • sound – Name of the sound file to be played with the message or a messaging.CriticalSound instance (optional).
  • content_available – A boolean indicating whether to configure a background update notification (optional).
  • category – String identifier representing the message type (optional).
  • thread_id – An app-specific string identifier for grouping messages (optional).
  • mutable_content – A boolean indicating whether to support mutating notifications at the client using app extensions (optional).
  • custom_data – A dict of custom key-value pairs to be included in the Aps dictionary (optional).
class firebase_admin.messaging.ApsAlert(title=None, subtitle=None, body=None, loc_key=None, loc_args=None, title_loc_key=None, title_loc_args=None, action_loc_key=None, launch_image=None, custom_data=None)

Bases: object

An alert that can be included in messaging.Aps.

Parameters:
  • title – Title of the alert (optional). If specified, overrides the title set via messaging.Notification.
  • subtitle – Subtitle of the alert (optional).
  • body – Body of the alert (optional). If specified, overrides the body set via messaging.Notification.
  • loc_key – Key of the body string in the app’s string resources to use to localize the body text (optional).