gpt4 book ai didi

iphone - Apple 推送通知增强格式

转载 作者:行者123 更新时间:2023-12-03 20:10:01 26 4
gpt4 key购买 nike

有人知道使用增强版协议(protocol)时如何从Apple推送通知服务获取错误响应吗?

最佳答案

根据Apple文档,如果我们使用增强版的Push协议(protocol),我们可以从 channel 获取错误响应,错误响应格式:

COMMAND(1 byte)|STATUS(1 byte)|ID(4 byte)

状态:

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)'

这里是示例代码:

...
socket = SSLSocket (
socket.socket()
, ssl_version = ssl.PROTOCOL_SSLv3
, certfile
)

socket.connect(apnsHost, apnsPort)

len_written = connectionContext.write(socket)

errors = []

# Wait for input from socket
inputready = select.select ([socket], [],[], 1)[0]

if inputready:
replyBlock = channel.recv (6)

errors = [] #will be filled with 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)

关于iphone - Apple 推送通知增强格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3884381/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com