check if service worker exists on navigator

This commit is contained in:
liamcottle
2025-02-16 20:11:28 +13:00
parent 9a1bc67799
commit b2873ec983

View File

@@ -62,6 +62,7 @@ for(const route of routes){
} }
// listen for postMessage events from service worker // listen for postMessage events from service worker
if(navigator.serviceWorker){
navigator.serviceWorker.addEventListener("message", async (event) => { navigator.serviceWorker.addEventListener("message", async (event) => {
if(event.data.type === "notificationclick"){ if(event.data.type === "notificationclick"){
@@ -76,6 +77,7 @@ navigator.serviceWorker.addEventListener("message", async (event) => {
} }
}); });
}
// access Connection class from window // access Connection class from window
// this allows typing "Connection.log = true" in Chrome dev tools // this allows typing "Connection.log = true" in Chrome dev tools