|
Setup
|
|
|
Webserver (Chrome required)
|
|
Online Tutorial
|
|
|
Google Drive
|
|
|
Generate Keys
|
|
Notification Click
|
sw.js
|
event.notifica‐ tion.close();
|
|
Notification Click
|
sw.js
|
clients.openWi‐ ndow('htt‐ ps://develop‐ ers.google.c‐ om/web/')
|
|
Unsubscribe
|
main.js
|
subscription.u‐ nsubscribe(); & updateSubscrip‐ tionOnServer‐ (null);
|
|
Public Private Key
|
|
|
Copy paste the subscription
|
located on bottom of the page
|
|
Service Worker
|
sw.js
|
navigator.serv‐ iceWorker.regis‐ ter('sw.js')
|
|
Attach key
|
main.js
|
const applicati‐ onServerPubl‐ icKey = '<Your Public Key>';
|
|
update-Btn()
|
main.js
|
enables / disables button depending on subscription of user | call in initializeUI()
|
|
Click Listener
|
initializeUI()
|
pushButton.add‐ EventListener('‐ click', function() {...}
|
|
subscribeUser()
|
main.js
|
swRegistrat‐ ion.pushMana‐ ger.subscribe({ userVisibleOnly: true, applicati‐ onServerKey: applicationServ‐ erKey }) .then(‐ function(subscr‐ iption) {...})
|
|
updateOnServer()
|
main.js
|
Sends subscription to the backend
|
|
Handle Push Event
|
sw.js
|
listens for the event and shows a notifi‐ cation (console.log)
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.