Re: [w3c/push-api] pushsubscriptionchange event doesn't have oldSubscription in it. (#325)

Hey @novaknole, thanks for following up!

1. Right.
2. Right. Firefox push subscriptions don't have a known expiration in advance, but the push server can drop them anytime. Firefox will also trigger `pushsubscriptionchange` if the user grants permission again after revoking it, like you discovered, or when the origin quota for the number of push messages is refreshed. So...
3. Yes, it's good to handle the event by resubscribing. In the latest draft of the spec, `old` and `new` are supplied automatically, so the browser makes a new subscription behind the scenes, and only passes it to `pushsubscriptionchange` once it's done. In the old draft that Firefox implements now, you have to call `registration.pushManager.subscribe()` again yourself. But...
4. You can't 😭 By the time the `pushsubscriptionchange` is triggered, the subscription is already gone. You'd need to use a session cookie or token stored in IndexedDB to identify the user, and overwrite their old subscription details with the new one based on that. [The Pushpad founder blogged about that limitation](https://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/) a while back.
5. It's a judgment call. I want to say "yes", since Firefox does trigger it, but I know it's really, really, really annoying to handle now, with all the caveats in (3) and (4). I can't say when Firefox will support the new event, since that work hasn't been prioritized yet—I haven't worked on push in a couple of years, and our wonderful DOM team is at capacity working on other projects.

I wish I had a more satisfying answer for you than "yes, but it's kinda broken now, and you have to use a super clunky workaround to make it work"...but that's the state of things today. Thank you for taking the time to write up all your questions, it's definitely appreciated!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/issues/325#issuecomment-624977849

Received on Thursday, 7 May 2020 01:34:17 UTC