Suppose I have installed Chrome for Android and have subscribed for push for a number of websites.
I then go to the App Settings on Android and clear data for Chrome as a whole.
What happens to the push subscription in this case? I suspect that we delete the data within Chrome, but does the subscription with Play Services continue to live? If so, we should unsubscribe automatically on next message; if not, does it tell the server about the unsubscription, so that it can return a 400 code when pushing for that user?
Comment 1 by joh...@chromium.org
, Feb 7 2017I can confirm that messages continue to be delivered to Chrome after app data is cleared, and they show up in chrome://gcm-internals (see screenshot). Of course, they don't then show a notification or anything since the subscription (PushMessagingAppIdentifier) and Service Worker no longer exist. Oddly, these incoming messages do not trigger automatic unsubscription (there are no entries for PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID in chrome://histograms, indeed the only push/GCM histogram that gets logged at all is GCM.Crypto.DecryptMessageResult), hence the subscription remains valid as far as the GCM server is concerned. That's because push messaging has not yet registered a GCMAppHandler, since it is not aware that there are any subscriptions. Subscribing for push on any website causes the GCMAppHandler to be added, and then the next time a message is sent to the old subscription is triggers PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID as expected, and hence the next time a message is sent after that (assuming the device was online) the GCM server responds {"error":"NotRegistered"} as expected, indicating to the push sender that this subscription is no longer valid. Possible ways to avoid the edge case: - Unconditionally register the GCMAppHandler on Android (not on desktop, since it's expensive there). - Convince Google Play Services to auto-unsubscribe registrations when data is cleared for an app. But this probably doesn't make sense for most Android apps which only have a single GCM subscription. It's not clear that either of these is worthwhile though, since the existing automatic unsubscription will eventually clean things up as long as the user subscribes to push on any website.184 KB
184 KB View Download