java-apns INVALID_TOKEN response

659 Views Asked by At

I'm using java-apns library for send push notification messages. I send token_id to APNS server and receive response INVALID_TOKEN. So my question is what algorithm APNS server use for this response? I think it would be better to check this token_id on my side and if it's ok then push message to this token. Thanks in advance.

1

There are 1 best solutions below

0
On

APNS does not offer any API to check whether a specific token is valid. An algorithm would not be useful either, as INVALID_TOKEN means not only a malformed token, but it is also returned when the token does not match any registered app, or the app has been uninstalled, or you used a development token to communicate to production APN server or vice versa.

The correct way of handling a invalid token is to send the message and, if you get an INVALID_TOKEN error, delete the token from your own server and don't use it anymore.

There is, however, the Feedback Service that you should query regularly in order to get tokens that have been unregistered recently.