The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/messaging

messaging package

Firebase Cloud Messaging

Functions

Function Description
deleteToken(messaging) Deletes the registration token associated with this FirebaseMessaging instance and unsubscribes the FirebaseMessaging instance from the push subscription.
getMessaging(app) Retrieves a Firebase Cloud Messaging instance.
getToken(messaging, options) Subscribes the FirebaseMessaging instance to push notifications. Returns an Firebase Cloud Messaging registration token that can be used to send push messages to that FirebaseMessaging instance.If a notification permission isn't already granted, this method asks the user for permission. The returned promise rejects if the user does not allow the app to show notifications.
isSupported() Copyright 2020 Google LLCLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
onMessage(messaging, nextOrObserver) When a push message is received and the user is currently on a page for your origin, the message is passed to the page and an onMessage() event is dispatched with the payload of the push message.

Interfaces

Interface Description
FcmOptions Options for features provided by the FCM SDK for Web. See WebpushFcmOptions
FirebaseMessaging Public interface of the Firebase Cloud Messaging SDK.
MessagePayload Message payload that contains the notification payload that is represented with NotificationPayload and the data payload that contains an arbitrary number of key-value pairs sent by developers through the Send API
NotificationPayload Display notification details. They are sent through the Send API