Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long is an APNS token valid for?

With APNS, when a device registers, how long is the token it registers with good for? The entire time the app is installed? I seem to recall a note in the documentation saying it was only good until sync/reset, but looking at the docs again I can't find that note (and it hasn't held true in my (admittedly non-extensive) testing). Can anyone confirm how long each token is valid for?

like image 548
Max Avatar asked Nov 17 '09 14:11

Max


1 Answers

In addition to changing when a device is wiped clean, a token for a app/device combo will also change when being debugged on a device with Xcode vs. when that same app is run from a released (app store) version of the app.

I ran into issues recently when I was storing multiple device tokens for my own phone. I had two tokens in our database for one phone. One was assigned to me when I was developing with Xcode and the other was assigned from the released version of the app.

The problem was the debug token only worked on the sandbox servers and the release token only worked on the production servers. When I was testing, I was sending alerts to both tokens and Apple would drop my SSL connection because one of them was invalid.

That being said, I believe Apple reserves the right to change them whenever they want, which is why it's necessary to request the token on every application launch.

I hope that helps.

like image 150
Sangraal Avatar answered Sep 27 '22 22:09

Sangraal