Hi, We're trying to move our APNs implementation to token based implementation instead of certificates, and have a few questions:
2. According to doc: “APNs reports an error if you recreate your tokens more than once every 20 minutes”. I tried creating several tokens, less than 20 minutes, and they all work...
3. What is the hard cap for creating provider token and avoid TooManyProviderTokenUpdates?
Thanks!
Oren
In the docs it says that only 1 token can be used at a time, and refresh it between 20 to 60 minutes.
2. According to doc: “APNs reports an error if you recreate your tokens more than once every 20 minutes”. I tried creating several tokens, less than 20 minutes, and they all work...
3. What is the hard cap for creating provider token and avoid TooManyProviderTokenUpdates?
Thanks!
Oren
Our suggestion would be to follow the guidance provided and not try to find and plan for an edge case you may have anectodally observed. This will only cause issues in production. Not sure what you expect to gain by wanting to create tokens more frequently.
Not sure why you are not getting the error in your tests, but if I had to guess, it is because you are closing the connections in between, and when you open a new connection you are hitting another APNs host altogether. As the guidance for connection life cycle is to open a connection and keep it open as long as you are able to, changing the token frequently on the same open connection will surely cause the error you are expecting.
On the other hand, if you have a need to change tokens frequently for a reason, and to be able to do that, you start closing and reopening the connections in quick succession, that may cause other issues if the APNs side thinks this fits a DoS pattern.
To summarize, the guidance for best outcome is: open a connection, and keep it open as long as you are able to. Create a new token as close to an hour before the old one expires, but no more frequently than once every 20 minutes.
Not sure why you are not getting the error in your tests, but if I had to guess, it is because you are closing the connections in between, and when you open a new connection you are hitting another APNs host altogether. As the guidance for connection life cycle is to open a connection and keep it open as long as you are able to, changing the token frequently on the same open connection will surely cause the error you are expecting.
On the other hand, if you have a need to change tokens frequently for a reason, and to be able to do that, you start closing and reopening the connections in quick succession, that may cause other issues if the APNs side thinks this fits a DoS pattern.
To summarize, the guidance for best outcome is: open a connection, and keep it open as long as you are able to. Create a new token as close to an hour before the old one expires, but no more frequently than once every 20 minutes.