Home > @firebase/messaging > getToken
getToken() function
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.
Signature:
export declare function getToken(messaging: FirebaseMessaging, options?: {
vapidKey?: string;
swReg?: ServiceWorkerRegistration;
}): Promise<string>;
Parameters
Parameter | Type | Description |
---|---|---|
messaging | FirebaseMessaging | The FirebaseMessaging instance. |
options |
Returns:
Promise<string>
The promise resolves with an FCM registration token.