diff --git a/components/serviceworker.js b/components/serviceworker.js index 6bb42e43..f6cb0368 100644 --- a/components/serviceworker.js +++ b/components/serviceworker.js @@ -99,7 +99,7 @@ export const ServiceWorkerProvider = ({ children }) => { // since (a lot of) browsers don't support the pushsubscriptionchange event, // we sync with server manually by checking on every page reload if the push subscription changed. // see https://medium.com/@madridserginho/how-to-handle-webpush-api-pushsubscriptionchange-event-in-modern-browsers-6e47840d756f - navigator.serviceWorker.controller.postMessage({ action: 'SYNC_SUBSCRIPTION' }) + navigator?.serviceWorker?.controller?.postMessage?.({ action: 'SYNC_SUBSCRIPTION' }) }, []) useEffect(() => { diff --git a/sw/index.js b/sw/index.js index 654caeb6..ccd95cf8 100644 --- a/sw/index.js +++ b/sw/index.js @@ -7,6 +7,7 @@ import { enable } from 'workbox-navigation-preload' import manifest from './precache-manifest.json' import ServiceWorkerStorage from 'serviceworker-storage' +// comment out to enable workbox console logs self.__WB_DISABLE_DEV_LOGS = true const storage = new ServiceWorkerStorage('sw:storage', 1) @@ -15,9 +16,6 @@ const storage = new ServiceWorkerStorage('sw:storage', 1) // https://developer.chrome.com/docs/workbox/modules/workbox-navigation-preload/ enable() -// uncomment to disable workbox console logs -// self.__WB_DISABLE_DEV_LOGS = true - // ignore precache manifest generated by InjectManifest // they statically check for the presence of this variable console.log(self.__WB_MANIFEST)