



V2 to start using the token-based version of the Push Notification extension.V1 and want to migrate your app to use V2, then Select V1 & V2 option. This ensures that the users viewing the older version of your app also receive Push Notifications.V2, thus turning off V1 (Topic-based) Push Notifications completely.

| Files | Description |
|---|---|
| index.html | Displays a simple User Login Form. |
| PushNotification.js | File with the logic to initialize CometChat and Firebase. |
| firebase-messaging-sw.js | Service worker shows Push Notifications when the tab is either in the background or closed. |

PushNotification.js.
index.html file should look like this:
importScripts to include the firebase-app.js and firebase-messaging.js files in the service worker.FIREBASE_CONFIG object again in this file.firebase-messaging-sw.js file should look like this:
FCM_TOKEN.FCM_TOKEN with the extension.login and logout functions in the PushNotifications.js file. You can copy paste the below code. Do not forget to replace the APP_ID, REGION, AUTH_KEY of your app in the code below.
FCM_TOKEN will be deleted on the extension’s end on the CometChat.logout() call.FCM_TOKEN should also be deleted using the firebase.messaging().deleteToken().CustomMessage, you need to set metadata while sending the CustomMessage.