0

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?

Christopher Smit
  • 953
  • 11
  • 27
  • you can check this.https://stackoverflow.com/questions/19782470/what-happen-if-a-apns-device-token-expired – Kumar Reddy Dec 20 '17 at 16:48
  • I know about that and I am following those steps to save the token and so on. But if I leave the project for a while and I try to send a notification again at a later stage with the token that worked a few hours ago without changing my code, nothing happens. I need to reinstall the app and get a new token for it to work, but that too will stop working again after a few hours – Christopher Smit Dec 20 '17 at 17:39
  • 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. – Kumar Reddy Dec 20 '17 at 17:43
  • Thanks, I hope this is just something weird with the sandbox environment. It seems like sometimes it pushes and sometimes it doesn’t. I literally just received 5 notifications that I tried sending earlier, maybe they just took a while to come through. If you want you can post your last comment as an answer and I’ll accept. – Christopher Smit Dec 20 '17 at 17:45

2 Answers2

1

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.

Kumar Reddy
  • 792
  • 6
  • 15
1

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.

Allison
  • 1,925
  • 1
  • 18
  • 25