From b410879ca9937140662a6f0a424cbe4061adf6fd Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 17 Feb 2021 18:36:17 -0800 Subject: [PATCH] google renamed a method, fixing --- service-worker.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service-worker.js b/service-worker.js index 216b8063..0532a405 100644 --- a/service-worker.js +++ b/service-worker.js @@ -3,8 +3,6 @@ importScripts('https://cdn.jsdelivr.net/npm/firebase@7.24.0/firebase-app.js'); importScripts('https://cdn.jsdelivr.net/npm/firebase@7.24.0/firebase-messaging.js'); importScripts('firebase-init.js'); -firebase.initializeApp(FIREBASE_INIT); - // Basic internationalization. const i18n = { 'de': { @@ -44,8 +42,13 @@ self.i18nMessage = function(id) { return lang[id] || i18n['en'][id] || id; } -// This method shows the push notifications. -firebase.messaging().setBackgroundMessageHandler((payload) => { +firebase.initializeApp(FIREBASE_INIT); +const fbMessaging = firebase.messaging(); + +// This method shows the push notifications while the window is in background. +fbMessaging.onBackgroundMessage((payload) => { + console.log("sw got background message", payload.data); + if (payload.data.silent == 'true') { return; }