From 1f7e2be523306500026b5929f1c009237439b251 Mon Sep 17 00:00:00 2001 From: Andrea Wu <1359259+andreaowu@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:23:54 +0500 Subject: [PATCH 1/3] Update firebase-messaging-sw.js --- messaging/firebase-messaging-sw.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/messaging/firebase-messaging-sw.js b/messaging/firebase-messaging-sw.js index 09ee4fc51..027931a9b 100644 --- a/messaging/firebase-messaging-sw.js +++ b/messaging/firebase-messaging-sw.js @@ -5,8 +5,6 @@ importScripts('/__/firebase/9.2.0/firebase-app-compat.js'); importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js'); importScripts('/__/firebase/init.js'); -const messaging = firebase.messaging(); - /** * Here is is the code snippet to initialize Firebase Messaging in the Service * Worker when your app is not hosted on Firebase Hosting. @@ -30,12 +28,11 @@ const messaging = firebase.messaging(); appId: 'app-id', measurementId: 'G-measurement-id', }); + **/ // Retrieve an instance of Firebase Messaging so that it can handle background // messages. const messaging = firebase.messaging(); - **/ - // If you would like to customize notifications that are received in the // background (Web app is closed or not in browser focus) then you should From 8cd4553903722f91cadc34691e21de0c918cb222 Mon Sep 17 00:00:00 2001 From: Andrea Wu <1359259+andreaowu@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:32:06 +0500 Subject: [PATCH 2/3] Update firebase-messaging-sw.js --- messaging/firebase-messaging-sw.js | 51 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/messaging/firebase-messaging-sw.js b/messaging/firebase-messaging-sw.js index 027931a9b..257c42be6 100644 --- a/messaging/firebase-messaging-sw.js +++ b/messaging/firebase-messaging-sw.js @@ -1,38 +1,35 @@ // Import and configure the Firebase SDK -// These scripts are made available when the app is served or deployed on Firebase Hosting +// Give the service worker access to Firebase Messaging +// Note that you can only use Firebase Messaging here. Other Firebase libraries +// are not available in the service worker. + +// These scripts are available when the app is served or deployed on Firebase Hosting // If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup importScripts('/__/firebase/9.2.0/firebase-app-compat.js'); importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js'); importScripts('/__/firebase/init.js'); -/** - * Here is is the code snippet to initialize Firebase Messaging in the Service - * Worker when your app is not hosted on Firebase Hosting. - - // Give the service worker access to Firebase Messaging. - // Note that you can only use Firebase Messaging here. Other Firebase libraries - // are not available in the service worker. - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); - importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); +// These scripts made available when the app is not served or deployed on Firebase Hosting +//importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); +//importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); - // Initialize the Firebase app in the service worker by passing in - // your app's Firebase config object. - // https://firebase.google.com/docs/web/setup#config-object - firebase.initializeApp({ - apiKey: 'api-key', - authDomain: 'project-id.firebaseapp.com', - databaseURL: 'https://project-id.firebaseio.com', - projectId: 'project-id', - storageBucket: 'project-id.appspot.com', - messagingSenderId: 'sender-id', - appId: 'app-id', - measurementId: 'G-measurement-id', - }); - **/ +// Initialize the Firebase app in the service worker by passing in +// your app's Firebase config object. +// https://firebase.google.com/docs/web/setup#config-object +// firebase.initializeApp({ +// apiKey: 'api-key', +// authDomain: 'project-id.firebaseapp.com', +// databaseURL: 'https://project-id.firebaseio.com', +// projectId: 'project-id', +// storageBucket: 'project-id.appspot.com', +// messagingSenderId: 'sender-id', +// appId: 'app-id', +// measurementId: 'G-measurement-id', +// }); - // Retrieve an instance of Firebase Messaging so that it can handle background - // messages. - const messaging = firebase.messaging(); +// Retrieve an instance of Firebase Messaging so that it can handle background +// messages. +const messaging = firebase.messaging(); // If you would like to customize notifications that are received in the // background (Web app is closed or not in browser focus) then you should From 9927a8841142c541edec9e44ac6e12792d3e9a43 Mon Sep 17 00:00:00 2001 From: Andrea Wu <1359259+andreaowu@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:57:05 +0500 Subject: [PATCH 3/3] Update firebase-messaging-sw.js --- messaging/firebase-messaging-sw.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/messaging/firebase-messaging-sw.js b/messaging/firebase-messaging-sw.js index 257c42be6..4765f1e61 100644 --- a/messaging/firebase-messaging-sw.js +++ b/messaging/firebase-messaging-sw.js @@ -2,16 +2,8 @@ // Give the service worker access to Firebase Messaging // Note that you can only use Firebase Messaging here. Other Firebase libraries // are not available in the service worker. - -// These scripts are available when the app is served or deployed on Firebase Hosting -// If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup -importScripts('/__/firebase/9.2.0/firebase-app-compat.js'); -importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js'); -importScripts('/__/firebase/init.js'); - -// These scripts made available when the app is not served or deployed on Firebase Hosting -//importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); -//importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); +importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-app-compat.js'); +importScripts('https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging-compat.js'); // Initialize the Firebase app in the service worker by passing in // your app's Firebase config object.