According to Apple's documentation, if we use an extended version of the Push protocol, we can get an error response from the channel, the format of the error is:
TEAM (1 byte) | STATUS (1 byte) | ID (4 bytes)
statuses:
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)'
here is an example code:
...
socket = SSLSocket (
socket.socket()
, ssl_version = ssl.PROTOCOL_SSLv3
, certfile
)
socket.connect(apnsHost, apnsPort)
len_written = connectionContext.write(socket)
errors = []
inputready = select.select ([socket], [],[], 1)[0]
if inputready:
replyBlock = channel.recv (6)
errors = []
while replyBlock:
command, status, id = struct.unpack_from('!BBL', replyBlock)
if status != 0:
errors.append((command, status, id))
replyBlock = channel.recv (6)
source
share