firebase-admin.messaging package Stay organized with collections Save and categorize content based on your preferences.
Firebase Cloud Messaging (FCM).
Functions
| Function | Description |
|---|---|
| getMessaging(app) | Gets theMessaging service for the default app or a given app.admin.messaging() can be called with no arguments to access the default app'sMessaging service or asadmin.messaging(app) to access theMessaging service associated with aspecific app. |
Classes
| Class | Description |
|---|---|
| FirebaseMessagingError | Firebase Messaging error code structure. This extends PrefixedFirebaseError. |
| Messaging | Messaging service bound to the provided app. |
| MessagingClientErrorCode | Messaging client error codes and their default messages. |
Interfaces
| Interface | Description |
|---|---|
| AndroidConfig | Represents the Android-specific options that can be included in anMessage. |
| AndroidFcmOptions | Represents options for features provided by the FCM SDK for Android. |
| AndroidNotification | Represents the Android-specific notification options that can be included inAndroidConfig. |
| ApnsConfig | Represents the APNs-specific options that can be included in anMessage. Refer toApple documentation for various headers and payload fields supported by APNs. |
| ApnsFcmOptions | Represents options for features provided by the FCM SDK for iOS. |
| ApnsPayload | Represents the payload of an APNs message. Mainly consists of theaps dictionary. But may also contain other arbitrary custom keys. |
| Aps | Represents theaps dictionary that is part of APNs messages. |
| ApsAlert | |
| BaseMessage | |
| BatchResponse | Interface representing the server response from theMessaging.sendEach() andMessaging.sendEachForMulticast() methods. |
| ConditionMessage | |
| CriticalSound | Represents a critical sound configuration that can be included in theaps dictionary of an APNs payload. |
| DataMessagePayload | Interface representing an FCM legacy API data message payload. Data messages let developers send up to 4KB of custom key-value pairs. The keys and values must both be strings. Keys can be any custom string, except for the following reserved strings:
|
| FcmOptions | Represents platform-independent options for features provided by the FCM SDKs. |
| LightSettings | Represents settings to control notification LED that can be included inAndroidNotification. |
| MessagingOptions | Interface representing the options that can be provided when sending a message via the FCM legacy APIs.SeeBuild send requests for code samples and detailed documentation. |
| MessagingPayload | Interface representing a Firebase Cloud Messaging message payload. One or both of thedata andnotification keys are required.SeeBuild send requests for code samples and detailed documentation. |
| MessagingTopicManagementResponse | Interface representing the server response from theMessaging.subscribeToTopic() andMessaging.unsubscribeFromTopic() methods.SeeManage topics from the server for code samples and detailed documentation. |
| MulticastMessage | Payload for theMessaging.sendEachForMulticast() method. The payload contains all the fields in the BaseMessage type, and a list of tokens. |
| Notification | A notification that can be included inMessage. |
| NotificationMessagePayload | Interface representing an FCM legacy API notification message payload. Notification messages let developers send up to 4KB of predefined key-value pairs. Accepted keys are outlined below.SeeBuild send requests for code samples and detailed documentation. |
| SendResponse | Interface representing the status of an individual message that was sent as part of a batch request. |
| TokenMessage | |
| TopicMessage | |
| WebpushConfig | Represents the WebPush protocol options that can be included in anMessage. |
| WebpushFcmOptions | Represents options for features provided by the FCM SDK for Web (which are not part of the Webpush standard). |
| WebpushNotification | Represents the WebPush-specific notification options that can be included inWebpushConfig. This supports most of the standard options as defined in the Web Notificationspecification. |
Type Aliases
| Type Alias | Description |
|---|---|
| Message | Payload for theMessaging.send() operation. The payload contains all the fields in the BaseMessage type, and exactly one of token, topic or condition. |
getMessaging(app)
Gets theMessaging service for the default app or a given app.
admin.messaging() can be called with no arguments to access the default app'sMessaging service or asadmin.messaging(app) to access theMessaging service associated with aspecific app.
Signature:
exportdeclarefunctiongetMessaging(app?:App):Messaging;Parameters
| Parameter | Type | Description |
|---|---|---|
| app | App | Optional app whoseMessaging service to return. If not provided, the defaultMessaging service will be returned. |
Returns:
The defaultMessaging service if no app is provided or theMessaging service associated with the provided app.
Example 1
// Get the Messaging service for the default appconstdefaultMessaging=getMessaging();Example 2
// Get the Messaging service for a given appconstotherMessaging=getMessaging(otherApp);Message
Payload for theMessaging.send() operation. The payload contains all the fields in the BaseMessage type, and exactly one of token, topic or condition.
Signature:
exporttypeMessage=TokenMessage|TopicMessage|ConditionMessage;Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-12 UTC.