只是使用「優先級」參數這裏是樣本,但我不能保證立即收到通知。
import time
from apns import APNs, Frame, Payload
apns = APNs(use_sandbox=True, cert_file='cert.pem', key_file='key.pem')
# Send a notification
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)
# Send multiple notifications in a single transmission
frame = Frame()
identifier = 1
expiry = time.time()+3600
priority = 10
frame.add_item('b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87', payload, identifier, expiry, priority)
apns.gateway_server.send_notification_multiple(frame)
嗨,我發現了: 'GatewayConnection' 對象沒有屬性 '_sent_notifications' 從上self._sent_notifications apns.py錯誤+ = frame.get_notifications(個體) – tomermes
HTTPS:// github上.COM/djacobs/PyAPNs /問題/ 108 – typedef