Back to Firebase Js Sdk

GetTokenOptions interface

docs-devsite/messaging_sw.gettokenoptions.md

12.12.13.0 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

GetTokenOptions interface

Options for getToken()<!-- -->.

<b>Signature:</b>

typescript
export interface GetTokenOptions 

Properties

PropertyTypeDescription
serviceWorkerRegistrationServiceWorkerRegistrationThe service worker registration for receiving push messaging. If the registration is not provided explicitly, you need to have a <code>firebase-messaging-sw.js</code> at your root location. See Access the registration token for more details.
vapidKeystringThe public server key provided to push services. The key is used to authenticate push subscribers to receive push messages only from sending servers that hold the corresponding private key. If it is not provided, a default VAPID key is used. Note that some push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended to generate and import a VAPID key for your project with Configure Web Credentials with FCM<!-- -->. See The Web Push Protocol for details on web push services.

GetTokenOptions.serviceWorkerRegistration

The service worker registration for receiving push messaging. If the registration is not provided explicitly, you need to have a firebase-messaging-sw.js at your root location. See Access the registration token for more details.

<b>Signature:</b>

typescript
serviceWorkerRegistration?: ServiceWorkerRegistration;

GetTokenOptions.vapidKey

The public server key provided to push services. The key is used to authenticate push subscribers to receive push messages only from sending servers that hold the corresponding private key. If it is not provided, a default VAPID key is used. Note that some push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended to generate and import a VAPID key for your project with Configure Web Credentials with FCM<!-- -->. See The Web Push Protocol for details on web push services.

<b>Signature:</b>

typescript
vapidKey?: string;