This needs to be a UInt8Array so we use our function mentioned before to convert our key.

For example, in my demo I used Mongo DB to save the subscriptions.

Here we will return a first notification welcoming the user once they subscribed.

First we have a look at the "push" event in our service worker.

There we check if we get a payload (title, body, icon..) from the server and if not fall back to a default message.

After that, we use the show Notification() method to show the notification to the user.

Note: In addition to title, body and icon the payload can also have other options like badge, tag or vibrate.

It should also be noted that some parts of the front-end are based on this tutorial Before starting with coding we need some prerequisites. You can get them either via this site or by installing the web-push library (which we will need later on the back-end) with on the terminal.

In both cases you will get a public key and a private key, which you should save at safe place.

At the time of writing this (February 2017) many of these are only available in some browsers.