iphone推送通知密码短语问题(pyAPns)

2024-06-07 12:09:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试基于PyAPNs为iphone实现推送通知

当我在本地运行它时,它会阻塞并提示我手动输入密码短语,直到我输入密码短语才起作用

我不知道如何设置它以便在没有提示的情况下工作

这是我的代码:

from apns import APNs, Payload
import optparse
import os


certificate_file = here(".." + app.fichier_PEM.url   )        
token_hex = '0c99bb3d077eeacdc04667d38dd10ca1a'
pass_phrase = app.mot_de_passe



apns = APNs(use_sandbox=True, cert_file= certificate_file)
payload = Payload(alert = message.decode('utf-8'), sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)


# Get feedback messages
for (token_hex, fail_time) in apns.feedback_server.items():
    print "fail: "+fail_time

Tags: importtokenapp密码apnsservertimecertificate
2条回答

创建不带短语的.pem文件时,请指定-nodes

创建不带短语的.pem文件

openssl pkcs12 -nocerts -out Pro_Key.pem -in App.p12 -nodes

使用短语创建.pem文件

openssl pkcs12 -nocerts -out Pro_Key.pem -in App.p12

如果你有一个带密码的.pem文件,你可以为PyAPNs去掉它的密码 使用以下命令

openssl rsa -in haspassword.pem -out nopassword.pem

参考

用于生成证书和其他配置。

一些与Apple推送通知服务(APNs)交互的Python库

尝试使用

apns = APNs(use_sandbox=True, cert_file='XYZCert.pem', key_file='XYZKey.pem')

指定证书和私钥的位置。

相关问题 更多 >

    热门问题