Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questions about keeping Service Worker Push Subscriptions In Sync

I've read the push subscription can get out of sync between the browser and the push service.

I've seen two remediations, both look to be non-standard:

  1. ServiceWorkerGlobalScope.onpushsubscriptionchange
  2. GCM send response, mentioned here, spelled out here
    • understandably non-standard

I presume any application should handle both of these points at which a subscription can be identified to be out-of-sync (and any/all).

Questions:

  1. In general, are there always just the two areas an application can be made aware of a subscription out-of-sync situation? (1. service worker event 2. push service response) Seems reasonable, looking for confirmation.
  2. Will the ServiceWorkerGlobalScope.onpushsubscriptionchange event (or some equivalent) make it into the authoritative standard?
  3. In lieu of a service worker event standard, why not just keep the expected subscription endpoint around (in client-side state) and anytime you query the PushManager for the subscription, check if it is out-of-sync (different than expected)?
like image 759
Alex Grant Avatar asked Oct 25 '25 12:10

Alex Grant


1 Answers

The pushsubscriptionchange event is documented as part of the Push API specification. That should be considered authoritative, and it mentions there onpushsubscriptionchange is exposed as part of ServiceWorkerGlobalScope.

I don't know offhand whether pushsubscriptionchange event is fired in all browsers that support the Push API as of this writing, but I believe the general idea is that it's the (eventual) solution to the use case you describe.

like image 199
Jeff Posnick Avatar answered Oct 28 '25 03:10

Jeff Posnick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!