Add priority option for sending notification
This commit is contained in:
+4
-2
@@ -21,10 +21,12 @@ class APNsClient(object):
|
|||||||
ssl_context.load_cert_chain(cert_file)
|
ssl_context.load_cert_chain(cert_file)
|
||||||
self.__connection = HTTP20Connection(server, port, ssl_context=ssl_context)
|
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')
|
json_payload = dumps(notification.dict(), ensure_ascii=False, separators=(',',':')).encode('utf-8')
|
||||||
headers = {}
|
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'apns-priority': prioriy.value
|
||||||
|
}
|
||||||
if topic:
|
if topic:
|
||||||
headers['apns-topic'] = topic
|
headers['apns-topic'] = topic
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from apns2.client import NotificationPriority
|
||||||
from apns2.payload import Payload
|
from apns2.payload import Payload
|
||||||
|
|
||||||
|
|
||||||
@@ -12,4 +13,5 @@ class APNsClient(object):
|
|||||||
def send_notification(self,
|
def send_notification(self,
|
||||||
token_hex: str,
|
token_hex: str,
|
||||||
notification: Payload,
|
notification: Payload,
|
||||||
|
prioriy: NotificationPriority = NotificationPriority.Immediate,
|
||||||
topic: Optional[str] = None) -> None: ...
|
topic: Optional[str] = None) -> None: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user