From 1a17b01f0cb4f15c99913b24e605129bdd2af3e8 Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 13 Feb 2019 15:28:26 +0300 Subject: [PATCH] add skipWaiting --- service-worker.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/service-worker.js b/service-worker.js index 7630e109..fe4c3d6f 100644 --- a/service-worker.js +++ b/service-worker.js @@ -20,9 +20,15 @@ firebase.messaging().setBackgroundMessageHandler(function(payload) { return self.registration.showNotification(title, options); }); +// Update service worker immediately for both the current client +// and all other active clients. +self.addEventListener('install', event => { + self.skipWaiting(); +}); + // This code handles a click on notification: takes // the user to the browser tab with the chat or opens a new tab. -self.addEventListener('notificationclick', function(event) { +self.addEventListener('notificationclick', event => { const notification = event.notification; notification.close(); @@ -68,7 +74,7 @@ self.addEventListener('notificationclick', function(event) { }); // This is needed for 'Add to Home Screen'. -self.addEventListener('fetch', function(event) { +self.addEventListener('fetch', event => { // Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=823392 if (event.request.cache == 'only-if-cached' && event.request.mode != 'same-origin') { return;