-
-
Save dbushell/39e35d5fa5404dfe7b555e98f0194619 to your computer and use it in GitHub Desktop.
Service Worker for Web Push API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('push', (ev) => { | |
// https://developer.apple.com/documentation/usernotifications/sending_web_push_notifications_in_safari_and_other_browsers | |
// >> Safari doesn’t support invisible push notifications. | |
// >> Present push notifications to the user immediately after your service worker receives them. | |
// >> If you don’t, Safari revokes the push notification permission for your site. | |
ev.waitUntil( | |
self.registration.showNotification('Push Message', { | |
body: ev.data?.text() ?? 'no data' | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment