mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-17 08:14:19 +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
|
||||
navigator.serviceWorker.addEventListener("message", async (event) => {
|
||||
if(event.data.type === "notificationclick"){
|
||||
if(navigator.serviceWorker){
|
||||
navigator.serviceWorker.addEventListener("message", async (event) => {
|
||||
if(event.data.type === "notificationclick"){
|
||||
|
||||
// get notification data
|
||||
const notificationData = event.data.data;
|
||||
// get notification 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
|
||||
// this allows typing "Connection.log = true" in Chrome dev tools
|
||||
|
||||
Reference in New Issue
Block a user