Send push notifications and retrieve a payload once a notification is received.
Send push notifications with a payload. This recipe shows how to send and receive a string, but data can be extracted from a Push message in a variety of formats (string, ArrayBuffer, Blob, JSON).
Show rich push notifications, defining the language of the notification, a vibration pattern, an image to associate to the notification. See https://notifications.spec.whatwg.org/#api for the other parameters you can set (e.g. a set of actions that can be activated from the notification).
Simplest example of Web Push API usage. Send notifications to users even when your page is not open.
Use the notification tag to replace old notifications with new ones. Allows you to show only up-to-date information to your users or collapse multiple notifications into a single one.
Experiment with the quota management policies of different browsers. Try sending many notifications (visible or invisible) and see what happens if you keep the tab open vs close it, or if you click on some notifications vs you click on none of them.
Control the clients of a service worker when the user clicks on a notification generated from a push event. Allows you to focus the tab of your app or even re-open it if it was closed.
This recipe shows how to use push notifications with subscription management.
Has it been useful?
Tell us what you think of this recipe by leaving a comment!