APNs token still valid after app uninstalled

Hi,


I was testing the push notification tokens, and I uninstall the app from the device after token was generated.

Then I tried to send push notification with that token which I expect to be invalidated/unregistered.

However, I'm still getting a success message with that token.

When will tokens get invalidated after uninstall? Thanks!

Replies

When you send the message to APNS, the success result you get is just "message successfully received by APNS and waiting for device."


When the device contacts APNS (which may never happen, or could happen immediately, depending on network connections, device load, and other factors), that's when the feedback service results are generated if the device is recognized by APNS as the same device. (There are other ways the system decides that the message is undeliverable, but they mostly require time...). But you need to use the feedback service to get that result.


If a device token changes, then you won't ever get negative feedback until some other device winds up with the same device token.

Hello,


Thanks for your response. So you're saying there is no way we can tell for sure if the device tokens are really valid?

I uninstalled the app, and reinstall it (so the tokens are updated), and I sent a new push notification. So I'm assuming the device contacts APNS? So then in this case, device might not be recognized as the same device by APNS?


Also, if the device token changes, how likely will some other device winds up with the same device token?


I'm trying to figure out why I have low delivery rate for our push notifications (I track when the device receive a push notification) so I want to know what cause the discrepancies. Not being able to know if the tokens are actually valid makes it more complicated to debug this.

Update:


Upon further testing, when testing with the release build, after I uninstall, and reinstall the app, the device token gets invalidated. If I don't reinstall, it still says token is still valid until I get notification from other service. When testing with the debug/dev APNs, the token is always showing valid regardless if you reinstall.


Can someone from Apple confirm if you uninstall app, the token won't be invalidated until you receive push notification from other app? My understanding from the technical note is if I have at least one other push-enabled app on my device, we'll get the notice of the deletion (device unregistered) ? It doesn't say if it needs to wait until it gets notification from other app.


Apple Technical note:

If you remove your app from your device or computer and then send a push notification to it, you would expect to have the device token rejected, and the invalidated device token should appear on the feedback service. However, if this was the last push-enabled app on the device or computer, it will not show up in the feedback service. This is because deleting the last app tears down the persistent connection to the push service before the notice of the deletion can be sent.

You can work around this by leaving at least one push-enabled app on the device or computer in order to keep the persistent connection up. To keep the persistent connection to the production environment up, just install any free push-enabled app from the App Store and you should then be able to delete your app and see it appear in the feedback service.

Recall that each push environment has its own persistent connection. So to keep the persistent connection to the sandbox environment up, install another development push-enabled app


https://developer.apple.com/library/content/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG34

There is nothing in the docs about the expiration time when Apple's APNs service will invalidate a device token.


The "doc"

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1


The "video"

https://developer.apple.com/videos/play/wwdc2016/724/ (15 minute video)


I use the newer Token Based Provider Connection Trust method which sends the HTTP requests and gets immediate feedback in the corresponding response.


The APNs Provider server I wrote handles errors returned within the responses. If its a bad token error (400) or unregistered (410), I pop the device token from my database. I have tried uninstalling, reinstalling, repeat ... to generate old device tokens on the APNs Provider server.

I have not seen one return an error message that its unregistered.

I added a last update time in my database recently with the development APNs service. I have some device tokens that are over 2 weeks old and are still accepted by the APNs service.

We have the same problem. We never get 410 back on a request to APNS using HTTP/2. Atleast, we have not yet. I was under the impression that the feedback service was legacy and not needed when using the HTTP/2 endpoint, since feedback was immidiate.


I guess this will be our strategy for this: Reregister devicetoken in our API whenever the app starts and keep devicetoken + timestamp of last re-registration. Decide to quit sending notifications to devicetokens that has not been touched for let's say three weeks.

Hi All,

I have also same issue
Is there any solution for it?

Thanks!

We have the same issue, we never receive an "Unregistered" from APNS. We do receive "Bad Token" if we use the production environment for development tokens for example.

It would be nice if the documentation would mention when this happens...