-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass removed subscriptions as a property of the pushsubscriptionchange
event
#193
Comments
That might be confused for the new subscription. Maybe call it |
+1 (obviously) I would like to remark that this issue should apply to the following cases:
|
Yeah, I think @johnmellor suggested this in #132 (comment). At that point, a "change" could mean a few things:
I feel like these cases are sufficiently different to where a single event doesn't fit them all. Maybe it's worth thinking about bringing OTOH, explaining |
Cases 1 and 3 are basically the same. And 2 is exceptional enough that I think we're OK. The subscribe attempt will fail and reject, but I think that's fine. It still gives the app a chance to notify the server that the old subscription is gone, which is one half of the purpose of the event. |
@martinthomson I agree, I think that |
Huge +1: right now a subscription endpoint in essence acts as the 'ID' of a push target. Developers are frequently going to be saving state on their app server associated with that push target ID, e.g. "this push target ID belongs to this user". If the push target ID is going to change that's all good, but any long-term service is going to have to be able to tell its app server "hey, this old ID should now be known as this new ID" If the EDIT: I'd argue @kitcambridge's case #2 doesn't meet this clear definition, so I suggest it alone get its own |
Actually you know what would be a hell of a lot simpler, and solve all the issues brought up in this thread? If each push target had a UUID that didn't change even if the subscription was refreshed, disabled, re-enabled, etc. That UUID would be used to track state on the app server instead of the subscription endpoint, so as long as we always have access to the UUID we would have no more need to know about the old subscription values in |
@mohamedhafez, we try really hard not to create super-cookies, which what you describe might cause. The problem is that you should not be using the push URI as a primary key. For the same reason that you wouldn't use an email address as a primary key (unless you like pain when it comes time to allow users to change their email address). Instead, make another primary key for the user and store the push URI against that primary key. |
@martinthomson maybe I wasn't clear, I'm already doing what you are suggesting, but the issue is: when the push URI changes to something else because the subscription refreshes, developers are going to need to know that it still belongs to the same user, that it is logically the same subscription just with updated values. |
Also I don't think what I'm suggesting counts as a super-cookie: it would get deleted for good when the service worker got deleted for good. I guess what I'm suggesting or what @kitcambridge suggested is already completely possible with things like IDB, but considering that it is something many developers are going to have to do, it would be nice if it was made easy. |
Since the subscription is coming from the same user, why is there anything new needed? Do you have multiple users who share the same browser (and service worker)? |
@martinthomson No, but with the current spec, unless I save either the user id or the old subscription info in IDB, how would the ServiceWorker know which user the new subscription is for in Storing that info is doable of course - it would just be nice if the browser would take care of that for us considering its going to be necessary for every developer trying to make user-specific push notifications reliable across refreshes. If giving an ID to subscriptions that stays the same across refreshes is out of the question, then simply including the old subscription info in |
This was addressed by #234 - |
Hi! So in VAPID
Can server rely on unique endpoint here to performing matching and replace the old subscription with the new one? Or having custom UUID / cookie session is the way to go here? Thanks. |
The endpoint can change. There is no guarantee that anything in the endpoint will remain constant for the same user. For that matter, there is no guarantee that the same endpoint won't be used for a different user either. If you want to identify users, give them an identifier (cookies or anything like that). |
@martinthomson thanks for info, that makes sense! |
Just came up with this situation:
So, if an endpoint can be used by multiple/different users: how the server should distinguish between the same browser/device or other one? |
Also spec explicitly says:
|
And the last: if a device/browser cannot be identified by endpoint or IDB entry + endpoint, then the only solution to uniquely mark a device/browser is to generate new |
Another though: can |
@collimarco points out in http://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/ that we don't currently pass the removed subscription when we fire
pushsubscriptionchange
. At that point,self.registration.pushManager.getSubscription()
will resolve tonull
, because the old subscription has been removed.An app can work around this by storing the subscription endpoint in IDB, then retrieving it when
pushsubscriptionchange
is fired. Alternatively, we can pass the old subscription along, maybe as a property on the event:The text was updated successfully, but these errors were encountered: