From e0244f38c22f8f860f7bb1672d82c3099fc0637e Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 15 May 2023 11:20:49 +0700 Subject: [PATCH] TF-1802 Fix fcm broken on web (cherry picked from commit a5c88da70482ff9dfad53b2c3582ec860ca237dc) --- web/firebase-messaging-sw.js | 6 ++++-- web/index.html | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/web/firebase-messaging-sw.js b/web/firebase-messaging-sw.js index 83f438981..f28471b41 100644 --- a/web/firebase-messaging-sw.js +++ b/web/firebase-messaging-sw.js @@ -1,6 +1,6 @@ importScripts("https://www.gstatic.com/firebasejs/9.10.0/firebase-app-compat.js"); importScripts("https://www.gstatic.com/firebasejs/9.10.0/firebase-messaging-compat.js"); - +// Initialize the Firebase app in the service worker by passing in the messagingSenderId. firebase.initializeApp({ apiKey: "...", authDomain: "...", @@ -9,4 +9,6 @@ firebase.initializeApp({ storageBucket: "...", messagingSenderId: "...", appId: "...", -}); \ No newline at end of file +}); +// Retrieve an instance of Firebase Messaging so that it can handle background messages. +const messaging = firebase.messaging(); \ No newline at end of file diff --git a/web/index.html b/web/index.html index 1954fb9a1..87b007f78 100644 --- a/web/index.html +++ b/web/index.html @@ -58,7 +58,12 @@ // Wait for registration to finish before dropping the