What should your server do when apns returns a 410 Unregistered error for your token?

For our Live Activity Tokens, when we fire a payload, often apns is returning a response of 410 unregistered.

Docs are saying:

The device token is inactive for the specified topic. There is no need to send further pushes to the same device token, unless your application retrieves the same device token, refer to Registering your app with APNs

Questions:

  1. Why does this happen? Does it only happen because the user changed their permission? Or there are other reasons?

  2. And when it does happen, what should we do about it?

A. Should we keep the token on the server? Because perhaps the user will change their permission and the token becomes valid? That could leave us with lots of invalid tokens and us firing at them unnecessarily.

Docs do say:

Don’t retry notification responses with the error code BadDeviceToken, DeviceTokenNotForTopic, Forbidden, ExpiredToken, Unregistered, or PayloadTooLarge.

B. Or should we remove the token from the server? That then requires app to re-register the token. But the problem with that is:

When I went into App's settings from OS settings and toggled push notifications to on, the app was not launched into the background nor killed i.e. it requires explicit app launch by the user to re-register itself which isn't ideal...

It means a user may turn on notifications from the OS settings and then assume that their push notifications should be back in business, but that won't happen if you toggle things from OS settings.

410 Unregistered is an irrecoverable and final error. Once you get that error, the server should remove that token from the list, as it will no longer reach anywhere.

It is only a signal to the push provider server that they should stop using that token. While we see some developers use this as a signal that the user has removed the app, that is not a necessarily correct interpretation of the error.

Although this could mean that the app may have been removed, it could also mean the token has changed while the app is still installed, and the old token is no longer useful. It is also possible that you would never get this error after an app is removed.

You will not get this error when the user changes notification settings. Nor changing those settings will change the token.

While it is possible that the user might turn off notifications for the app, then after a while the token changes due to an unrelated reason, and then the user turns notifications back on again - and all this time the app has not been launched to get the new token, that is an unfortunate edge case that there is no viable solution.

When I went into App's settings from OS settings and toggled push notifications to on, the app was not launched into the background nor killed i.e. it requires explicit app launch by the user to re-register itself which isn't ideal...

This reads like you are sending background notifications and expecting the app to be launched in response. One thing to remember is that if an app has not been used for a long time (meaning it has not been launched by the user), it wouldn't be launched in the background by a notification anyways, correct token or not.

So, apps needing to be regularly launched and used is a necessity in your case.


Argun Tekant /  WWDR Engineering / Core Technologies

What should your server do when apns returns a 410 Unregistered error for your token?
 
 
Q