|
|
@ -5,7 +5,7 @@ importScripts( |
|
|
|
); |
|
|
|
|
|
|
|
self.addEventListener("install", (event) => { |
|
|
|
console.error(event); |
|
|
|
console.error("Adding event listener for:", event); |
|
|
|
importScripts( |
|
|
|
"safari-notifications.js", |
|
|
|
"nacl.js", |
|
|
@ -23,7 +23,8 @@ self.addEventListener("push", function (event) { |
|
|
|
payload = JSON.parse(event.data.text()); |
|
|
|
} |
|
|
|
const message = await self.getNotificationCount(); |
|
|
|
console.error(message); |
|
|
|
if (message) { |
|
|
|
console.log("Will notify user:", message); |
|
|
|
const title = payload ? payload.title : "Custom Title"; |
|
|
|
const options = { |
|
|
|
body: message, |
|
|
@ -31,8 +32,11 @@ self.addEventListener("push", function (event) { |
|
|
|
badge: payload ? payload.badge : "badge.png", |
|
|
|
}; |
|
|
|
await self.registration.showNotification(title, options); |
|
|
|
} else { |
|
|
|
console.log("No notification message, so will not tell the user."); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error("Error in processing the push event:", error); |
|
|
|
console.error("Error processing the push event:", error); |
|
|
|
} |
|
|
|
})(), |
|
|
|
); |
|
|
@ -51,7 +55,7 @@ self.addEventListener("activate", (event) => { |
|
|
|
}); |
|
|
|
|
|
|
|
self.addEventListener("fetch", (event) => { |
|
|
|
console.log(event.request); |
|
|
|
console.log("Got fetch event", event.request); |
|
|
|
}); |
|
|
|
|
|
|
|
self.addEventListener("error", (event) => { |
|
|
|