Files
2026-08-23 09:04:47 +00:00

24 lines
683 B
JavaScript

import { precacheAndRoute } from 'workbox-precaching'
precacheAndRoute(self.__WB_MANIFEST)
self.addEventListener('push', (event) => {
let data = { title: 'Dyna Biz Coignières', body: '' }
try {
if (event.data) data = event.data.json()
} catch {}
const options = {
body: data.body,
icon: data.icon || '/logo.svg',
badge: data.badge || '/favicon.svg',
data: { url: data.data?.url || '/' },
}
event.waitUntil(self.registration.showNotification(data.title, options))
})
self.addEventListener('notificationclick', (event) => {
event.notification.close()
const url = event.notification.data?.url || '/'
event.waitUntil(clients.openWindow(url))
})