Firebase Cloud Messaging (FCM).

## Functions

| Function | Description |
|---|---|
| [getMessaging(app)](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#getmessaging_8a40afc) | Gets the [Messaging](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messaging_class) service for the default app or a given app.`admin.messaging()` can be called with no arguments to access the default app's `Messaging` service or as `admin.messaging(app)` to access the `Messaging` service associated with aspecific app. |

## Classes

| Class | Description |
|---|---|
| [FirebaseMessagingError](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.firebasemessagingerror#firebasemessagingerror_class) | Firebase Messaging error code structure. This extends `FirebaseError`. |
| [Messaging](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messaging_class) | Messaging service bound to the provided app. |

## Interfaces

| Interface | Description |
|---|---|
| [AndroidConfig](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.androidconfig#androidconfig_interface) | Represents the Android-specific options that can be included in an [Message](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#message). |
| [AndroidFcmOptions](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.androidfcmoptions#androidfcmoptions_interface) | Represents options for features provided by the FCM SDK for Android. |
| [AndroidNotification](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.androidnotification#androidnotification_interface) | Represents the Android-specific notification options that can be included in [AndroidConfig](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.androidconfig#androidconfig_interface). |
| [ApnsConfig](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.apnsconfig#apnsconfig_interface) | Represents the APNs-specific options that can be included in an [Message](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#message). Refer to [Apple documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for various headers and payload fields supported by APNs. |
| [ApnsFcmOptions](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.apnsfcmoptions#apnsfcmoptions_interface) | Represents options for features provided by the FCM SDK for iOS. |
| [ApnsPayload](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.apnspayload#apnspayload_interface) | Represents the payload of an APNs message. Mainly consists of the `aps` dictionary. But may also contain other arbitrary custom keys. |
| [Aps](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.aps#aps_interface) | Represents the [aps dictionary](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html) that is part of APNs messages. |
| [ApsAlert](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.apsalert#apsalert_interface) |   |
| [BaseMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.basemessage#basemessage_interface) |   |
| [BatchResponse](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.batchresponse#batchresponse_interface) | Interface representing the server response from the [Messaging.sendEach()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingsendeach) and `sendEachForMulticast` methods. |
| [ConditionMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.conditionmessage#conditionmessage_interface) |   |
| [CriticalSound](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.criticalsound#criticalsound_interface) | Represents a critical sound configuration that can be included in the `aps` dictionary of an APNs payload. |
| [FcmOptions](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.fcmoptions#fcmoptions_interface) | Represents platform-independent options for features provided by the FCM SDKs. |
| [FidMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.fidmessage#fidmessage_interface) | Interface representing a message that targets a Firebase Installation ID (FID). |
| [FidMulticastMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.fidmulticastmessage#fidmulticastmessage_interface) | Payload for the `sendEachForMulticast` method containing only FIDs. |
| [LightSettings](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.lightsettings#lightsettings_interface) | Represents settings to control notification LED that can be included in [AndroidNotification](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.androidnotification#androidnotification_interface). |
| [MessagingTopicManagementResponse](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messagingtopicmanagementresponse#messagingtopicmanagementresponse_interface) | Interface representing the server response from the [Messaging.subscribeToTopic()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingsubscribetotopic) and [Messaging.unsubscribeFromTopic()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingunsubscribefromtopic) methods.See [Manage topics from the server](https://firebase.google.com/docs/cloud-messaging/manage-topics) for code samples and detailed documentation. |
| [MulticastMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.multicastmessage#multicastmessage_interface) | Payload for the `sendEachForMulticast` method. |
| [Notification](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.notification#notification_interface) | A notification that can be included in [Message](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#message). |
| [SendResponse](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.sendresponse#sendresponse_interface) | Interface representing the status of an individual message that was sent as part of a batch request. |
| [TokenMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.tokenmessage#tokenmessage_interface) |   |
| [TopicMessage](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.topicmessage#topicmessage_interface) |   |
| [WebpushConfig](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.webpushconfig#webpushconfig_interface) | Represents the WebPush protocol options that can be included in an [Message](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#message). |
| [WebpushFcmOptions](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.webpushfcmoptions#webpushfcmoptions_interface) | Represents options for features provided by the FCM SDK for Web (which are not part of the Webpush standard). |
| [WebpushNotification](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.webpushnotification#webpushnotification_interface) | Represents the WebPush-specific notification options that can be included in [WebpushConfig](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.webpushconfig#webpushconfig_interface). This supports most of the standard options as defined in the Web Notification [specification](https://developer.mozilla.org/en-US/docs/Web/API/notification/Notification). |

## Variables

| Variable | Description |
|---|---|
| [MessagingErrorCode](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#messagingerrorcode) | The constant mapping for valid Messaging client error codes. |

## Type Aliases

| Type Alias | Description |
|---|---|
| [Message](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#message) | Payload for the [Messaging.send()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingsend) operation. The payload contains all the fields in the BaseMessage type, and exactly one of fid, token (deprecated, use fid instead), topic or condition. |
| [MessagingErrorCode](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging#messagingerrorcode) | The type definition for valid Messaging client error codes. |

## getMessaging(app)

Gets the [Messaging](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messaging_class) service for the default app or a given app.

`admin.messaging()` can be called with no arguments to access the default app's `Messaging` service or as `admin.messaging(app)` to access the `Messaging` service associated with aspecific app.

**Signature:**

    export declare function getMessaging(app?: App): Messaging;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| app | App | Optional app whose `Messaging` service to return. If not provided, the default `Messaging` service will be returned. |

**Returns:**

[Messaging](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messaging_class)

The default `Messaging` service if no app is provided or the `Messaging` service associated with the provided app.

### Example 1

    // Get the Messaging service for the default app
    const defaultMessaging = getMessaging();

### Example 2

    // Get the Messaging service for a given app
    const otherMessaging = getMessaging(otherApp);

## MessagingErrorCode

The constant mapping for valid Messaging client error codes.

**Signature:**

    MessagingErrorCode: {
        readonly INVALID_ARGUMENT: "invalid-argument";
        readonly INVALID_RECIPIENT: "invalid-recipient";
        readonly INVALID_PAYLOAD: "invalid-payload";
        readonly INVALID_DATA_PAYLOAD_KEY: "invalid-data-payload-key";
        readonly PAYLOAD_SIZE_LIMIT_EXCEEDED: "payload-size-limit-exceeded";
        readonly INVALID_OPTIONS: "invalid-options";
        readonly INVALID_REGISTRATION_TOKEN: "invalid-registration-token";
        readonly REGISTRATION_TOKEN_NOT_REGISTERED: "registration-token-not-registered";
        readonly INSTALLATION_ID_NOT_REGISTERED: "installation-id-not-registered";
        readonly MISMATCHED_CREDENTIAL: "mismatched-credential";
        readonly INVALID_PACKAGE_NAME: "invalid-package-name";
        readonly DEVICE_MESSAGE_RATE_EXCEEDED: "device-message-rate-exceeded";
        readonly TOPICS_MESSAGE_RATE_EXCEEDED: "topics-message-rate-exceeded";
        readonly TOPICS_SUBSCRIPTION_RATE_EXCEEDED: "topics-subscription-rate-exceeded";
        readonly MESSAGE_RATE_EXCEEDED: "message-rate-exceeded";
        readonly THIRD_PARTY_AUTH_ERROR: "third-party-auth-error";
        readonly TOO_MANY_TOPICS: "too-many-topics";
        readonly AUTHENTICATION_ERROR: "authentication-error";
        readonly SERVER_UNAVAILABLE: "server-unavailable";
        readonly INTERNAL_ERROR: "internal-error";
        readonly UNKNOWN_ERROR: "unknown-error";
    }

## Message

Payload for the [Messaging.send()](https://firebase.google.com/docs/reference/admin/node/firebase-admin.messaging.messaging#messagingsend) operation. The payload contains all the fields in the BaseMessage type, and exactly one of fid, token (deprecated, use fid instead), topic or condition.

**Signature:**

    export type Message = FidMessage | TokenMessage | TopicMessage | ConditionMessage;

## MessagingErrorCode

The type definition for valid Messaging client error codes.

**Signature:**

    export type MessagingErrorCode = typeof MessagingErrorCode[keyof typeof MessagingErrorCode];