frontend/public/sw/push.js
Nathan Lamy 660017edda
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m24s
feat: add service worker
2025-08-19 22:56:00 +02:00

20 lines
506 B
JavaScript

self.addEventListener("push", onPush);
async function onPush(event) {
if (event.data) {
const data = event.data.json();
const { title, ...rest } = data;
// Send the push data to the application
const clients = await self.clients.matchAll();
clients.forEach((client) => client.postMessage(data));
await event.waitUntil(
self.registration.showNotification(title, {
...rest,
})
);
}
}
// self.addEventListener("notificationclick", function (event) {});