mirror of
https://github.com/zoldar/jenot.git
synced 2026-01-05 07:02:55 +00:00
22 lines
567 B
JavaScript
22 lines
567 B
JavaScript
const notificationIcon = "/img/android-chrome-192x192.png";
|
|
|
|
export function notificationsEnabled() {
|
|
return Notification.permission === "granted";
|
|
}
|
|
|
|
export function authorizeNotifications(afterCallback) {
|
|
Notification.requestPermission(function (permission) {
|
|
sendNotification(
|
|
"notification",
|
|
"Jenot can now send you alerts about reminders!",
|
|
);
|
|
afterCallback();
|
|
});
|
|
}
|
|
|
|
export function sendNotification(titleSuffix, message) {
|
|
return new Notification(`Jenot ${titleSuffix}`, {
|
|
body: message,
|
|
icon: notificationIcon,
|
|
});
|
|
}
|