diff --git a/apns2/client.py b/apns2/client.py index d0dd8ea..66ffcf4 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -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) diff --git a/apns2/client.pyi b/apns2/client.pyi index f6b3bcd..9d585df 100644 --- a/apns2/client.pyi +++ b/apns2/client.pyi @@ -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: ...