This website shows how to make and handle persistent notifications.
It registers a service worker, whose job is to handle notifications. When the "Notify me!" button is clicked, the website does the following:
registration.showNotification()
, passing in two
actions.
The notification presents the actions to the user. If the user clicks the
notification, then the browser starts the service worker, if it is not
already running, and dispatches the
notificationclick
event. If the user selected an action, then
the event object includes the selected action.
The service worker's notificationclick
handler checks the
value of the event's action
, and responds by opening the
appropriate web page.