The Firebase Messaging service interface.
This module is available for the default app only.
Get the Messaging service for the default app:
const defaultAppMessaging = firebase.messaging();
FirebaseApp instance for this Firebase service.
Returns whether messaging auto initialization is enabled or disabled for the device.
Returns a boolean value whether the user has registered for remote notifications via
Removes access to an FCM token previously authorized by it's scope. Messages sent by the server to this token will fail.
deleteToken(authorizedEntity?: undefined | string, scope?: undefined | string): Promise<void>;
On iOS, it is possible to get the users APNs token. This may be required if you want to send messages to your iOS devices without using the FCM service.
getAPNSToken(): Promise<string | null>;
When a notification from FCM has triggered the application to open from a quit state,
this method will return a
RemoteMessage containing the notification data, or
the app was opened via another method.
Returns an FCM token for this device. Optionally you can specify a custom authorized entity or scope to tailor tokens to your own use-case.
getToken(authorizedEntity?: undefined | string, scope?: undefined | string): Promise<string>;
AuthorizationStatus as to whether the user has messaging permission for this app.
Called when the FCM server deletes pending messages. This may be due to:
onDeletedMessages(listener: () => void): () => void;
When any FCM payload is received, the listener callback is called with a
onMessage(listener: (message: RemoteMessage) => any): () => void;
When sending a
RemoteMessage, this listener is called when the message has been sent to FCM.
onMessageSent(listener: (messageId: string) => any): () => void;
When the user presses a notification displayed via FCM, this listener will be called if the app has opened from a background state.
onNotificationOpenedApp(listener: (message: RemoteMessage) => any): () => void;
When sending a
RemoteMessage, this listener is called when an error is thrown and the
message could not be sent.
onSendError(listener: (evt: SendErrorEvent) => any): () => void;
Called when a new registration token is generated for the device. For example, this event can happen when a token expires or when the server invalidates the token.
onTokenRefresh(listener: (token: string) => any): () => void;
On iOS, if your app wants to receive remote messages from FCM (via APNs), you must explicitly register with APNs if auto-registration has been disabled.
On iOS, messaging permission must be requested by the current application before messages can be received or sent.
Send a new
RemoteMessage to the FCM server.
Sets whether auto initialization for messaging is enabled or disabled.
setAutoInitEnabled(enabled: boolean): Promise<void>;
On Android, set a message handler function which is called when the app is in the background or terminated. A headless task is created, allowing you to access the React Native environment to perform tasks such as updating local storage, or sending a network request.
Apps can subscribe to a topic, which allows the FCM server to send targeted messages to only those devices subscribed to that topic.
subscribeToTopic(topic: string): Promise<void>;
Unregisters the app from receiving remote notifications.
Unsubscribe the device from a topic.
unsubscribeFromTopic(topic: string): Promise<void>;