Rollen Freigaben Push und Beleg Upload ueberarbeiten
This commit is contained in:
34
public/sw.js
34
public/sw.js
@@ -43,3 +43,37 @@ self.addEventListener("fetch", (event) => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("push", (event) => {
|
||||
const payload = event.data?.json() ?? {};
|
||||
const title = payload.title || "RFP Finanzen";
|
||||
const options = {
|
||||
body: payload.body || "Es gibt eine neue Benachrichtigung.",
|
||||
icon: "/icon-192.png",
|
||||
badge: "/icon-192.png",
|
||||
tag: payload.tag || "rfp-finance",
|
||||
data: {
|
||||
url: payload.url || "/"
|
||||
}
|
||||
};
|
||||
|
||||
event.waitUntil(self.registration.showNotification(title, options));
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
event.notification.close();
|
||||
const targetUrl = new URL(event.notification.data?.url || "/", self.location.origin).href;
|
||||
|
||||
event.waitUntil(
|
||||
clients.matchAll({ type: "window", includeUncontrolled: true }).then((clientList) => {
|
||||
for (const client of clientList) {
|
||||
if ("focus" in client) {
|
||||
client.navigate(targetUrl);
|
||||
return client.focus();
|
||||
}
|
||||
}
|
||||
|
||||
return clients.openWindow(targetUrl);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user