我通过apns发送带有以下代码的ios通知:
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)
是否可以选择以更高的优先级发送它?有些用户收到通知的时间很长。
答案 0 :(得分:1)
只需使用" priority"这里的参数是样本,但我不能保证会立即收到通知。
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)