Added native os notifications

This commit is contained in:
2026-07-01 22:11:24 +10:00
parent d1b50e2f1a
commit 84379baf6a
19 changed files with 213 additions and 39 deletions
-24
View File
@@ -1,24 +0,0 @@
self.addEventListener('push', (event) => {
const data = event.data.json();
event.waitUntil(
self.registration.showNotification(data.title, {
body: data.body,
icon: data.icon || '/icons/trophy-192.png',
badge: '/icons/badge-72.png',
data: data.data,
})
);
});
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const url = event.notification.data?.url || '/';
event.waitUntil(
clients.matchAll({ type: 'window' }).then((clientList) => {
for (const client of clientList) {
if (client.url.includes(url) && 'focus' in client) return client.focus();
}
if (clients.openWindow) return clients.openWindow(url);
})
);
});