Add priority option for sending notification

This commit is contained in:
Sergey Petrov
2016-02-09 16:51:42 +03:00
parent 3f61fac159
commit 515bf64ae4
2 changed files with 9 additions and 5 deletions
+4 -2
View File
@@ -21,10 +21,12 @@ class APNsClient(object):
ssl_context.load_cert_chain(cert_file)
self.__connection = HTTP20Connection(server, port, ssl_context=ssl_context)
def send_notification(self, token_hex, notification, topic=None):
def send_notification(self, token_hex, notification, prioriy=NotificationPriority.Immediate, topic=None):
json_payload = dumps(notification.dict(), ensure_ascii=False, separators=(',',':')).encode('utf-8')
headers = {}
headers = {
'apns-priority': prioriy.value
}
if topic:
headers['apns-topic'] = topic