schedule local notifications that don't require a network connection
Notifirecreate
if ('showTrigger' in Notification.prototype) { const createScheduledNotification = async (tag, title, timestamp) => { const registration = await navigator.serviceWorker.getRegistration(); registration.showNotification(title, { tag: tag, body: 'This notification was scheduled 30 seconds ago', showTrigger: new TimestampTrigger(timestamp + 30 * 1000), }); }; }
cancel
const cancelScheduledNotification = async (tag) => { const registration = await navigator.serviceWorker.getRegistration(); const notifications = await registration.getNotifications({ tag: tag, includeTriggered: true, }); notifications.forEach((notification) => notification.close()); };
demo
Notification Triggers
https://notification-triggers.glitch.me/
Notification Triggers
The Notification Triggers API allows developers to schedule local notifications that don't require a network connection, which makes them ideal for use cases like calendar apps.
https://web.dev/notification-triggers/


Seonglae Cho