mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-17 16:24:18 +01:00
check if service worker exists on navigator
This commit is contained in:
24
src/main.js
24
src/main.js
@@ -62,20 +62,22 @@ for(const route of routes){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// listen for postMessage events from service worker
|
// listen for postMessage events from service worker
|
||||||
navigator.serviceWorker.addEventListener("message", async (event) => {
|
if(navigator.serviceWorker){
|
||||||
if(event.data.type === "notificationclick"){
|
navigator.serviceWorker.addEventListener("message", async (event) => {
|
||||||
|
if(event.data.type === "notificationclick"){
|
||||||
|
|
||||||
// get notification data
|
// get notification data
|
||||||
const notificationData = event.data.data;
|
const notificationData = event.data.data;
|
||||||
|
|
||||||
|
// if notification data includes vue-route-push, push the route to vue
|
||||||
|
const vueRoutePush = notificationData["vue-route-push"];
|
||||||
|
if(vueRoutePush){
|
||||||
|
await router.push(vueRoutePush);
|
||||||
|
}
|
||||||
|
|
||||||
// if notification data includes vue-route-push, push the route to vue
|
|
||||||
const vueRoutePush = notificationData["vue-route-push"];
|
|
||||||
if(vueRoutePush){
|
|
||||||
await router.push(vueRoutePush);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user