diff --git a/src/App.vue b/src/App.vue index 143e7ae..b732aee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -329,6 +329,7 @@ export default class App extends Vue { }) .then((subscription) => { if (subscription) { + console.log(subscription); return this.sendSubscriptionToServer(subscription); } else { throw new Error("Subscription object is not available."); @@ -369,15 +370,15 @@ export default class App extends Vue { private subscribeToPush(): Promise { return new Promise((resolve, reject) => { if ("serviceWorker" in navigator && "PushManager" in window) { + const applicationServerKey = this.urlBase64ToUint8Array(this.b64); + const options: PushSubscriptionOptions = { + userVisibleOnly: true, + applicationServerKey: applicationServerKey, + }; + console.log(options); + navigator.serviceWorker.ready .then((registration) => { - const applicationServerKey = this.urlBase64ToUint8Array(this.b64); - - const options: PushSubscriptionOptions = { - userVisibleOnly: true, - applicationServerKey: applicationServerKey, - }; - return registration.pushManager.subscribe(options); }) .then((subscription) => { @@ -385,7 +386,7 @@ export default class App extends Vue { resolve(); }) .catch((error) => { - console.error("Push subscription failed:", error); + console.error("Push subscription failed:", error, options); reject(error); }); } else {