使用pyapns从python中的APN返回'None'

时间:2016-12-16 08:54:05

标签: php node.js django python-2.7 safari

在开始时,Notifications(Safari)发送时回复为“无”,但现在通知没有发送,两种情况下响应都相同 -

我的有效载荷格式 -

payload = Payload(alert={
                                 "title": "Test",
                                 "body": "Test message",
                                 "action": "View"
                                 }, sound="default", badge=1,url_arg={"name":"https://www.google.com",},)

我的完整视图(代码): -

rom apns import APNs, Frame, Payload
    apns = APNs(use_sandbox=False, cert_file='cert.pem', key_file='key.pem',enhanced=True)
    print "11"
    # Send a notification
    payload = Payload({
        "aps": {
            "alert": {
                "title": "Flight A998 Now Boarding",
                "body": "Boarding has begun for Flight A998.",
                "action":"View"
            },
            "url-args": ["boarding", "clicked"]
        }
    })
    # alert={
    #                             "title": "Test",
    #                             "body": "Test message",
    #                             "action": "View"
    #                             }, sound="default", badge=1,url_arg={"name":"https://www.google.com",},)
    token_hex = 'FA47BC7C526AFE0A31A30B2EFE1A2AD1DB5A9935B16C9A81B706FDA7619B1B55'
    print '123345'
    frame = Frame()
    identifier = 1
    expiry = time.time()+3600
    priority = 10
    saf_sub=['FA47BC7C526AFE0A31A30B2EFE1A2AD1DB5A9935B16C9A81B706FDA7619B1B55','FA47BC7C526AFE0A31A30B2EFE1A2AD1DB5A9935B16C9A81B706FDA7619B1B55']
    for i in saf_sub:
            if i !=  '':
                try:
                    frame.add_item(str(i), payload, identifier, expiry, priority)
                except:
                    pass
    try:
            # print 'output',output
            output =apns.gateway_server.send_notification_multiple(frame)
            print 'output',output
    return Response({"status":output})
    except:
            pass

为什么没有(代码= 255)来自apns ??

任何建议???

0 个答案:

没有答案