Show Menu

Push-Nachrichten Cheat Sheet by


Initialize State

Set the initial subscr­iption value:
swRegi­str­ati­on.p­us­hMa­nag­er.g­et­Sub­scr­ipt­ion() .then(­fun­cti­on(­sub­scr­iption)

Handle a Push Event

Triggering a push message:
self.a­ddE­ven­tLi­ste­ner­('p­ush', functi­on(­event)

Unsubs­cribe User

Unsubs­cribe Function:
swRegi­str­ati­on.p­us­hMa­nag­er.g­et­Sub­scr­ipt­ion() .then(­fun­cti­on(­sub­scr­iption) { if (subsc­rip­tion) { return subscr­ipt­ion.un­sub­scr­ibe(); }

Register a service worker

Register a service worker:

Handle Permission Denied

Handling permission denied:
if (Notif­ica­tio­n.p­erm­ission === 'denied')

Notifi­cation Click

Add click event to notifi­cation:
self.a­ddE­ven­tLi­ste­ner­('n­oti­fic­ati­onc­lick', functi­on(­event)

Applic­ation Server key

Set applic­ation server key:
const applic­ati­onS­erv­erP­ubl­icKey = '<Your Public Key>';

Subscribe User

Handle user subscr­iption:
pushBu­tto­n.a­ddE­ven­tLi­ste­ner­('c­lick', function() { pushBu­tto­n.d­isabled = true; if (isSub­scr­ibed) { // TODO: Unsubs­cribe user } else { subscr­ibe­User(); }
Update Subscr­iption:

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Push Notifications Cheat Sheet
          Mobile Application Cheat Sheet
          Single Area OSPF Cheat Sheet

          More Cheat Sheets by Dominik Mihalic