2016-03-06 84 views
0

我通過APNS發送通知的ios用下面的代碼:發送推送通知與pyapns優先

from apns import APNs, Payload 

apns = APNs(cert_file='***.pem',key_file='***.pem') 
payload = Payload(alert=message, badge=1) 
apns.gateway_server.send_notification(token, payload) 

有以更高的優先級發送的選項?有些用戶正在收到通知,導致延遲很大。

回答

1

只是使用「優先級」參數這裏是樣本,但我不能保證立即收到通知。

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) 
+0

嗨,我發現了: 'GatewayConnection' 對象沒有屬性 '_sent_notifications' 從上self._sent_notifications apns.py錯誤+ = frame.get_notifications(個體) – tomermes

+0

HTTPS:// github上.COM/djacobs/PyAPNs /問題/ 108 – typedef