- Service worker
- Push service
-
Detect browser support
if (!("serviceWorker" in navigator)) { // Service Worker isn't supported on this browser, disable or hide UI. return; } if (!("PushManager" in window)) { // Push isn't supported on this browser, disable or hide UI. return; }
-
Register a service worker
-
Request permission
-
Subscribe a user with PushManager
-
Send message to Push service
-
Handle Push event & display Notification
self.addEventListener('push', function(event) { const notifPromise = self.registration.showNotification('Hello, World.'); event.waitUntil(notifPromise); });