Created
January 29, 2018 04:11
-
-
Save jasminabasurita/d06620ef456b2eb28ba84a8241c257bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function unsubscribePush() { | |
navigator.serviceWorker.ready.then(registration => { | |
//Find the registered push subscription in the service worker | |
registration.pushManager | |
.getSubscription() | |
.then(subscription => { | |
if (!subscription) { | |
return | |
//If there isn't a subscription, then there's nothing to do | |
} | |
` | |
subscription | |
.unsubscribe() | |
.then(() => axios.delete("/api/push/unregister")) | |
.catch(err => console.error(err)) | |
}) | |
.catch((err) => console.error(err)) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment