Meaning Of Different Status Codes In APNS Error Re

2019-03-09 20:41发布

问题:

APNS returns the following status codes in error response packets when using the enhanced notification format.

0   - No errors encountered
1   - Processing error
2   - Missing device token
3   - Missing topic
4   - Missing payload
5   - Invalid token size
6   - Invalid topic size
7   - Invalid payload size
8   - Invalid token
255 - None (unknown)

I want to know which of these status codes actually indicate that the issue is actually with the device token (ie: I can mark that particular device token in my database as invalid or inactive). I am sure that I can safely do that when I receive a value of 8 as status code. Also, I am pretty sure about what status codes 2, 4, 5 and 7 indicate and when exactly are they returned.

But for the rest of the status codes, I am pretty much in the dark. Apple's website does not contain much information about them either.

Can anybody please enlighten me about each of these status codes in detail. Many thanks in advance.

回答1:

You're right about the 2, 4, 5, 7, and 8. 0 is good news obviously. We're left with:

1   - Processing error
3   - Missing topic
6   - Invalid topic size
10  - Shutdown
255 - None (unknown)

1 is a problem on Apple's side, not related to the token.

3 is, according to Apple :

The topic is currently the bundle identifier of the target application on an iOS device.

6 is related to 3.

10 is out of your control but good to handle as well.

And obviously, 255 will not be able to help you define if the token is the problem.

If your goal is to determine a token that was valid at some point and no longer is, you should really refer to the Feedback Service API.