From 394db405713b5de059b001b1973b62e3e5b30ceb Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 16 Feb 2024 12:37:05 -0800 Subject: [PATCH] shot in the dark testing changes for notifications bug --- webtexting-worker.js | 2 +- webtexting.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/webtexting-worker.js b/webtexting-worker.js index 9595618..093d02f 100644 --- a/webtexting-worker.js +++ b/webtexting-worker.js @@ -37,7 +37,7 @@ self.addEventListener('push', function (event) { }); self.addEventListener('notificationclick', function (event) { - e.notification.close(); + event.notification.close(); event.waitUntil( self.clients.matchAll().then(function (clientList) { var tab = clientList.some(function (client) { diff --git a/webtexting.js b/webtexting.js index 48043b3..db1f156 100644 --- a/webtexting.js +++ b/webtexting.js @@ -58,7 +58,7 @@ async function toggleNotifications() { method: "POST", body: JSON.stringify({ endpoint: subscription.toJSON(), - state: currentState == "on" || currentState == "all" ? "off" : "on", + state: (currentState == "on" || currentState == "all") ? "off" : "on", extension_uuid: window.notification_data.extension_uuid, remote_identifier: window.notification_data.remote_identifier, }), @@ -104,10 +104,12 @@ if (window.notification_data) { const state = await registration.pushManager.permissionState({userVisibleOnly:true}); console.log("push notification permission state:", state); if (state == "denied") { + console.log("Push notification permissions denied. Please contact support@accleratenetworks.com.") return; } var subscription = await registration.pushManager.getSubscription(); + console.log("permissionState = " , permissionState) var buttonState = {state: "off"}; if(subscription) { console.log(subscription.toJSON());