Browse Source

avoid error on browsers without a service worker

kb/add-usage-guide
Trent Larson 10 months ago
parent
commit
61c3a0e30b
  1. 6
      src/App.vue

6
src/App.vue

@ -353,7 +353,7 @@ export default class App extends Vue {
}
}
// there may be a long pause here on first initialization
navigator.serviceWorker.ready.then(() => {
navigator.serviceWorker?.ready.then(() => {
this.serviceWorkerReady = true;
});
}
@ -443,7 +443,7 @@ export default class App extends Vue {
this.subscribeToPush()
.then(() => {
console.log("Subscribed successfully.");
return navigator.serviceWorker.ready;
return navigator.serviceWorker?.ready;
})
.then((registration) => {
return registration.pushManager.getSubscription();
@ -575,7 +575,7 @@ export default class App extends Vue {
async turnOffNotifications() {
let subscription;
const pushProviderSuccess = await navigator.serviceWorker.ready
const pushProviderSuccess = await navigator.serviceWorker?.ready
.then((registration) => {
return registration.pushManager.getSubscription();
})

Loading…
Cancel
Save