Files
uptime-kuma/src/serviceWorker.ts
T
Frank Elsinga 0f61d7ee1b chore: enable formatting over the entire codebase in CI (#6655)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-09 02:10:36 +01:00

24 lines
712 B
TypeScript

// Needed per Vite PWA docs
import { precacheAndRoute } from "workbox-precaching";
declare let self: ServiceWorkerGlobalScope;
precacheAndRoute(self.__WB_MANIFEST);
// 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);
}
}
});