mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-03 00:37:01 +00:00
Also fixed webpush wrong msg Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
19 lines
546 B
JavaScript
19 lines
546 B
JavaScript
// 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);
|
|
}
|
|
}
|
|
});
|