0

I'm sending ios notifications through apns with the following code:

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)

is there an option to send it with higher priority? Some users are getting the notifications with a significant delay.

tomermes
  • 22,950
  • 16
  • 43
  • 67

1 Answers1

1

just use "priority" parameter here is sample, but I can`t guarantee that notification will be received immediately.

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)
typedef
  • 917
  • 5
  • 9
  • Hi, I'm getting: 'GatewayConnection' object has no attribute '_sent_notifications' as an error from apns.py on self._sent_notifications += frame.get_notifications(self) – tomermes Mar 08 '16 at 15:33