Cheatography
https://cheatography.com
First Steps
Setup |
|
Webserver (Chrome required) |
|
Some basic links for the exercise!
Links
Online Tutorial |
|
Google Drive |
|
Generate Keys |
|
These links were used to perform the exercise!
Supplementary Features
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); |
sw.js and main.js are included in the setup folder!
|
|
Activate Push Notification
Public Private Key |
|
Copy paste the subscription |
located on bottom of the page |
Basic changes from the original
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) |
sw.js and main.js are included in the setup folder!
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by bausac16