This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const VER = 6
|
||||
const VER = 7
|
||||
|
||||
self.addEventListener('message', async (event) => {
|
||||
event.waitUntil(debug(event.source, Object.assign({ answer: true }, event.data)))
|
||||
@@ -27,12 +27,18 @@ self.addEventListener('push', (event) => {
|
||||
if (!pushData || !pushData.notification.title) {
|
||||
console.error('Received WebPush with an empty title. Received body: ', pushData)
|
||||
}
|
||||
self.registration
|
||||
.showNotification(pushData.notification.title, pushData.notification.options)
|
||||
.then(function () {
|
||||
// You can save to your analytics fact that push was shown
|
||||
// fetch('https://your_backend_server.com/track_show?message_id=' + pushData.data.message_id);
|
||||
})
|
||||
event.waitUntil(
|
||||
self.registration
|
||||
.showNotification(pushData.notification.title, pushData.notification.options)
|
||||
.then(function () {
|
||||
// You can save to your analytics fact that push was shown
|
||||
// fetch('https://your_backend_server.com/track_show?message_id=' + pushData.data.message_id);
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.waitUntil(handleNotificationClick(event))
|
||||
})
|
||||
|
||||
async function handleNotificationClick(event) {
|
||||
@@ -57,10 +63,6 @@ async function handleNotificationClick(event) {
|
||||
await openURL(event.notification.data.url)
|
||||
}
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.waitUntil(handleNotificationClick(event))
|
||||
})
|
||||
|
||||
async function openURL(urlToOpen) {
|
||||
let matchedClients
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user