问题描述
我正在尝试基于 PyAPNs 为 iphone 实现推送通知
I'm trying to implement push notifications for iphone based on PyAPNs
当我在本地运行它但它阻止并提示我手动输入密码并且在我输入之前不起作用
When I run it on local but it blocks and prompts me to enter the passphrase manually and doesn't work until I do
我不知道如何设置以便在没有提示的情况下工作
I don't know how to set it up so to work without prompt
这是我的代码:
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
推荐答案
当你创建一个没有短语的 .pem 文件时指定 -nodes
When you create a .pem file without phrase specify -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 文件,你可以 为 PyAPN 去掉它的密码 使用以下内容
If you have a .pem file with password you can get rid of its password for PyAPNs using the following
openssl rsa -in haspassword.pem -out nopassword.pem
参考
用于制作证书和其他配置.
for make certificates and other configurations.
一些用于与 Apple 推送通知服务 (APN) 交互的 Python 库
Some Python library for interacting with the Apple Push Notification service (APNs)
这篇关于iphone 推送通知密码问题 (pyAPns)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!