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;
}
// show notification
new window.Notification(title, {
// show notification via service worker
if(navigator.serviceWorker){
navigator.serviceWorker.ready.then(function(registration) {
registration.showNotification(title, {
body: body,
icon: "/icon.png",
});
});
}
}