- Node 8.6+
- Packages express, body-parser for the server
- Package web-push for easier works with the Web Push infrastructure, based in the https://serviceworke.rs/push-simple_demo.html Mozilla stuff
This sample was based in the Mozilla sample and also the Google doc Web Push Notifications: Timely, Relevant, and Precise.
However, here I wanted to be more clear because the Mozilla and Google is confusing for starters. Check my video walking with you and try yourself!
This is for Chrome okay? So,
- Open chrome://serviceworker-internals
- Open chrome://settings/content/notifications
- node 10_prepare_keys.js
- save the keys in the 15_vapid_keys.json
- node 20_serve-key.js
- // load the browser http://localhost:8080
- // Dont click allow yet
- // Check the console for the server, see that it served the public key!
- // Keep the page loaded browser http://localhost:8080
- node 30-serve-register.js
- // Click allow
- // Notice this does nothing in the server, it dumps the subscription to the screen
- // and asks you to save
- // assumes that you have copied the subscription data from the above step
- // into the 35_config_user_data.json
- node 40-eventually-notify.js
- // will delay a bit and send the notification to the subscription service
- // expect a notification to appear in the desktop