@firebase/messaging/sw Stay organized with collections Save and categorize content based on your preferences.
Functions
| Function | Description |
|---|---|
| function(app, ...) | |
| getMessaging(app) | Retrieves a Firebase Cloud Messaging instance. |
| function(messaging, ...) | |
| experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, enable) | Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By default, message delivery metrics are not exported to BigQuery. Use this method to enable or disable the export at runtime. |
| onBackgroundMessage(messaging, nextOrObserver) | Called when a message is received while the app is in the background. An app is considered to be in the background if no active window is displayed. |
| function() | |
| isSupported() | Checks whether all required APIs exist within SW Context |
Interfaces
| Interface | Description |
|---|---|
| FcmOptions | Options for features provided by the FCM SDK for Web. SeeWebpushFcmOptions. |
| GetTokenOptions | Options forgetToken(). |
| MessagePayload | Message payload that contains the notification payload that is represented withNotificationPayload and the data payload that contains an arbitrary number of key-value pairs sent by developers through theSend API. |
| Messaging | Public interface of the Firebase Cloud Messaging SDK. |
| NotificationPayload | Display notification details. Details are sent through theSend API. |
function(app, ...)
getMessaging(app)
Retrieves a Firebase Cloud Messaging instance.
Signature:
exportdeclarefunctiongetMessagingInSw(app?:FirebaseApp):Messaging;Parameters
| Parameter | Type | Description |
|---|---|---|
| app | FirebaseApp |
Returns:
The Firebase Cloud Messaging instance associated with the provided firebase app.
function(messaging, ...)
experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, enable)
Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By default, message delivery metrics are not exported to BigQuery. Use this method to enable or disable the export at runtime.
Signature:
exportdeclarefunctionexperimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging:Messaging,enable:boolean):void;Parameters
| Parameter | Type | Description |
|---|---|---|
| messaging | Messaging | TheFirebaseMessaging instance. |
| enable | boolean | Whether Firebase Cloud Messaging should export message delivery metrics to BigQuery. |
Returns:
void
onBackgroundMessage(messaging, nextOrObserver)
Called when a message is received while the app is in the background. An app is considered to be in the background if no active window is displayed.
Signature:
exportdeclarefunctiononBackgroundMessage(messaging:Messaging,nextOrObserver:NextFn<MessagePayload>|Observer<MessagePayload>):Unsubscribe;Parameters
| Parameter | Type | Description |
|---|---|---|
| messaging | Messaging | TheMessaging instance. |
| nextOrObserver | NextFn<MessagePayload> |Observer<MessagePayload> | This function, or observer object withnext defined, is called when a message is received and the app is currently in the background. |
Returns:
To stop listening for messages execute this returned function
function()
isSupported()
Checks whether all required APIs exist within SW Context
Signature:
exportdeclarefunctionisSwSupported():Promise<boolean>;Returns:
Promise<boolean>
a Promise that resolves to a boolean.
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-01-19 UTC.