Christopher Smit
Christopher Smit

Reputation: 969

APNS Tokens - Do iOS Sandbox tokens expire?

Just out of curiosity, do sandbox push notifications for iOS expire? The reason I am asking is, yesterday my push notifications were working perfectly for my device and since then I haven't changed the code. Today I wanted to push another notification to further test and all of a sudden, no notification was received. I had to reinstall the app and get another token for it to work.

So, do sandbox tokens expire, or do I possibly have a more serious issue at hand when I go to live?

Upvotes: 0

Views: 887

Answers (2)

Allison
Allison

Reputation: 2333

The device token probably changed from the prior version of the app you were testing. You should check the token each time you launch the app and ensure it's registered because it's likely to periodically change.

https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns

Never cache device tokens in local storage. APNs issues a new token when the user restores a device from a backup, when the user installs your app on a new device, and when the user reinstalls the operating system. If you ask the system to provide the token each time, you’re guaranteed to get an up-to-date token.

Upvotes: 1

Kumar Reddy
Kumar Reddy

Reputation: 802

As of now nowhere it is documented regarding the token expiry. But as an experience and from an architectural point, device tokens will not expire for a smaller duration of time. Because it will create a lot of effort for APNS to generate a new token every time if that is the case. Anyway, you can check your server logs to see the acknowledgement you receive from APNS if it is a failure to deliver a notification.

Upvotes: 1

Related Questions