Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如果一个设备令牌无效,APNSWrapper推送通知将无法发送到其他设备_Python_Ios_Push Notification - Fatal编程技术网

Python 如果一个设备令牌无效,APNSWrapper推送通知将无法发送到其他设备

Python 如果一个设备令牌无效,APNSWrapper推送通知将无法发送到其他设备,python,ios,push-notification,Python,Ios,Push Notification,我们使用以下代码来传递APNS通知 iHPush: def __init__(self): self.wrapper = APNSWrapper.APNSNotificationWrapper('/path/to/my/production.pem', False) def push(self, token='', alertmessage='', ubadge=0): deviceToken = binascii.unhexlify(token) message =

我们使用以下代码来传递APNS通知

iHPush:
def __init__(self):
    self.wrapper = APNSWrapper.APNSNotificationWrapper('/path/to/my/production.pem', False)

def push(self, token='', alertmessage='', ubadge=0):
    deviceToken = binascii.unhexlify(token)
    message = APNSWrapper.APNSNotification()
    message.token(deviceToken)
    message.badge(1)
    message.alert(alertmessage)
    message.sound()
    self.wrapper.append(message)

def notify(self):
    self.wrapper.notify()

pushObj = iHPush()
#this token is used for sandbox test
pushObj.push("b9236...x0", "haha", 0)
#this one is production token
pushObj.push("b9236...40", "haha", 0)
pushObj.notify()
在一条通知消息中组合沙箱和生产令牌将导致不传递通知。如果我们将第二个添加两次,消息将成功发送


我理解,如果令牌有效或无效,应由APNS处理。为什么我们不能用这种方式发送消息?

我无法解释为什么,但我可以问你为什么要设计这样的应用程序?您应该知道是否正在测试,因此您应该知道是否要与沙箱或生产网关通信,以及使用哪个设备id,这要感谢Paulw11。我担心如果一个生产令牌无效,例如,用户已卸载我们的应用程序,它是否会影响以下onesOk。这是有道理的。你需要订阅反馈服务,以接收关于交付失败的通知,这样你就可以从数据库中删除设备,但我同意你是正确的-交付失败是一种可能性,应该由苹果方面来处理。在python库方面进行一些调试可能是值得的——如果出现问题,苹果会提供一个反馈错误代码,但“无效令牌”不在其中。