support for apns-expiration header https://developer.apple.com/library/tvos/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html
This commit is contained in:
+4
-1
@@ -21,7 +21,7 @@ class APNsClient(object):
|
||||
ssl_context.load_cert_chain(cert_file)
|
||||
self.__connection = HTTP20Connection(server, port, ssl_context=ssl_context, force_proto=proto or 'h2')
|
||||
|
||||
def send_notification(self, token_hex, notification, priority=NotificationPriority.Immediate, topic=None):
|
||||
def send_notification(self, token_hex, notification, priority=NotificationPriority.Immediate, topic=None, expiration=None):
|
||||
json_payload = dumps(notification.dict(), ensure_ascii=False, separators=(',', ':')).encode('utf-8')
|
||||
|
||||
headers = {
|
||||
@@ -30,6 +30,9 @@ class APNsClient(object):
|
||||
if topic:
|
||||
headers['apns-topic'] = topic
|
||||
|
||||
if expiration is not None:
|
||||
headers['apns-expiration'] = "%d" % expiration
|
||||
|
||||
url = '/3/device/{}'.format(token_hex)
|
||||
stream_id = self.__connection.request('POST', url, json_payload, headers)
|
||||
resp = self.__connection.get_response(stream_id)
|
||||
|
||||
+2
-1
@@ -14,4 +14,5 @@ class APNsClient(object):
|
||||
token_hex: str,
|
||||
notification: Payload,
|
||||
priority: NotificationPriority = NotificationPriority.Immediate,
|
||||
topic: Optional[str] = None) -> None: ...
|
||||
topic: Optional[str] = None,
|
||||
expiration: Optional[int] = None) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user