Send notifications via service worker

This commit is contained in:
Adrian Gruntkowski 2024-11-16 19:10:27 +01:00
parent ad85a07030
commit 217d1ee87d

View file

@ -14,9 +14,11 @@ export function authorizeNotifications(afterCallback) {
}); });
} }
export function sendNotification(titleSuffix, message) { export async function sendNotification(titleSuffix, message) {
return new Notification(`Jenot ${titleSuffix}`, { return navigator.serviceWorker.ready.then((registration) =>
body: message, registration.showNotification(`Jenot ${titleSuffix}`, {
icon: notificationIcon, body: message,
}); icon: notificationIcon,
}),
);
} }