use service worker to show notifications

This commit is contained in:
liamcottle
2025-02-13 18:48:24 +13:00
parent 51d02ccf6b
commit 9e4a6c8726

View File

@@ -8,11 +8,15 @@ class NotificationUtils {
return; return;
} }
// show notification // show notification via service worker
new window.Notification(title, { if(navigator.serviceWorker){
body: body, navigator.serviceWorker.ready.then(function(registration) {
icon: "/icon.png", registration.showNotification(title, {
}); body: body,
icon: "/icon.png",
});
});
}
} }