JUNOHUB-test/public/sw.js
2026-02-16 12:16:27 +05:00

26 lines
648 B
JavaScript

self.addEventListener('push', function (event) {
if (event.data) {
const data = event.data.json()
const options = {
body: data.body,
icon: '/icon-192.png',
badge: '/badge.png',
data: {
url: data.url || '/'
},
actions: data.actions || []
}
event.waitUntil(
self.registration.showNotification(data.title, options)
)
}
})
self.addEventListener('notificationclick', function (event) {
event.notification.close()
event.waitUntil(
clients.openWindow(event.notification.data.url)
)
})