Skip to content

Instantly share code, notes, and snippets.

@jasminabasurita
Created January 29, 2018 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasminabasurita/d06620ef456b2eb28ba84a8241c257bc to your computer and use it in GitHub Desktop.
Save jasminabasurita/d06620ef456b2eb28ba84a8241c257bc to your computer and use it in GitHub Desktop.
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