iphone - Apple push notification enhanced format -
does know how error response apple push notification service when enhanced version of protocol used?
according apple documentation if using enhanced version of push protocol can error response channel, error respose format:
command(1 byte)|status(1 byte)|id(4 byte)
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 example code:
... socket = sslsocket ( socket.socket() , ssl_version = ssl.protocol_sslv3 , certfile ) socket.connect(apnshost, apnsport) len_written = connectioncontext.write(socket) errors = [] # wait input socket inputready = select.select ([socket], [],[], 1)[0] if inputready: replyblock = channel.recv (6) errors = [] #will filled error responses while replyblock: #error-response packet #command(1)|status(1)|id(4) command, status, id = struct.unpack_from('!bbl', replyblock) if status != 0: errors.append((command, status, id)) replyblock = channel.recv (6)
Comments
Post a Comment