You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/public/sw.js

19 lines
546 B

// Receive push notifications
self.addEventListener("push", function (event) {
if (self.Notification?.permission !== "granted") {
console.error("Notifications aren't supported or permission not granted!");
return;
}
if (event.data) {
let message = event.data.json();
try {
self.registration.showNotification(message.title, {
body: message.body,
});
} catch (error) {
console.error("Failed to show notification:", error);
}
}
});