Skip to content

Instantly share code, notes, and snippets.

@Serginho
Last active March 18, 2019 18:36
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 Serginho/fce2b5d92459ae02ee90f08f9c98202c to your computer and use it in GitHub Desktop.
Save Serginho/fce2b5d92459ae02ee90f08f9c98202c to your computer and use it in GitHub Desktop.
push subscriptionchange upload token null
async handlePush(event: PushSubscriptionChangeEvent) {
const req = new Request('/refreshpushsubscription', {
method: 'POST',
body: JSON.stringify(
{oldSubscription: event.oldSubscription, newSubscription: event.newSubscription})
});
const response = await self.fetch(req);
}
self.addEventListener('pushsubscriptionchange', (event: PushSubscriptionChangeEvent) =>
event.waitUntil(handlePush(event)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment