owltide/public/sw.js
Hornwitser 250ca9a1ac Port application from Next.js to Nuxt
Nuxt is based on Vue.js and I find their building blocks to be much
neater compared to the React based Next.js.
2025-03-05 15:36:50 +01:00

25 lines
500 B
JavaScript

self.addEventListener("push", function (event) {
console.log(event);
if (!event.data)
return;
const payload = event.data.json();
const { body, icon, image, badge, url, title } = payload;
const notificationTitle = title ?? "No title";
const notificationOptions = {
body,
icon,
image,
data: {
url,
},
badge,
};
event.waitUntil(
self.registration.showNotification(notificationTitle, notificationOptions)
.then(() => {
console.log("Web push delivered");
})
);
});