VAPID Web Push
VAPID is an abbreviation for "Voluntary Application Server Identification" and is fully described in the VAPID IETF specification.
VAPID is supported by all standard browsers (Firefox, Chrome, Opera, Edge) except Safari.
The most important to understand about VAPID is, how it can be used. And this is much easier as for the Safari browser. All what a customer needs to do is to
-
create a public/private key pair. This can - for example - be done by using a specific NodeJS library.
-
store the key pair in the UI

-
initialize the Web SDK with the public key and the URL of the service worker.

-
invoke the
subscribemethod of the Web SDK
|
The customer is well advised to combine - right from the start - the calling of the |
|
Changes to the key pair are very problematic as soon as a website is in use, because the change invalidates all previously collected push tokens (in the case of VAPID called "subscriptions"). |
|
It is very important that the service worker code must be hosted in the root of the website domain.
This is the reason why you see just something like "service-worker.js" in the SDK initialization
code. The
|
Service Workers
Service workers are an essential part of Web Push notification delivery in browsers that support VAPID. The service worker is a kind of service which is running in the browsers background. It registers itself for reception of push notification and notification click events.
Once a notification event is received, the service worker is assembling the message based on the received data and triggers the display of the notification.
Another responsibility of the service worker is the forwarding to a page if the user clicks on the notification. In such a case the service worker will also report an open event to the respective Web Push backend (device event service).