July 2018
Intermediate to advanced
354 pages
8h 51m
English
The pushsubscriptionchange event is particularly handy if the subscription is automatically removed due to the subscription becoming stale. This can happen because many push services limit the lifetime of a subscription for security and due to inactivity.
Just like authentication tokens, push subscriptions can be seamlessly renewed without involving the user. This is what you can do in the service worker for a push subscription.
The pushsubscriptionchange event includes an oldSubscription object that contains the details of the original subscription. They can be used to create a new subscription:
self.addEventListener('pushsubscriptionchange', e => { e.waitUntil(registration.pushManager.subscribe(e.oldSubscription.options) ...Read now
Unlock full access