Push Messages
Push Messaging is the well-known re-engagement mechanism from the mobile platforms. It allows the authorized Web applications to subscribe the user for the remotely sent messages that can trigger displaying a notification to the subscriber even if the Web application is not currently focused or even opened in the browser. The message can convey encrypted payload and can request displaying custom action buttons.
The Web Platform standard for Push Messages, Push API, utilizes the powerful concept of Service Workers, code units installable by the Web app that execute separately from the app itself. Push API also requires HTTPS installation.
There is also a non-standard proprietary solution available for OS X in Safari, based on Apple's own notification service, with the workflow similar to standard Push API, available via window.safari.pushNotification
interface.
API glimpse
serviceWorkerRegistration.pushManager.subscribe()
- Subscribes a user for the remote Push Messages. Returns a
Promise
. serviceWorkerRegistration.pushManager.getSubscription()
- Returns a
Promise
indicating current Push Messages subscription state. serviceWorker.addEventListener('push', listener)
- An event fired when remote push message has been received, available within Service Worker instance.