From 50c5920592395cfdf3cf622924cac71bcc8722f8 Mon Sep 17 00:00:00 2001 From: firkeuf Date: Fri, 13 May 2016 12:02:10 +0300 Subject: [PATCH 1/2] Update client.py hyper > common > util > to_bytestring can not convert INT to byte and raise ValueError("Non string type.") --- apns2/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apns2/client.py b/apns2/client.py index 2fa9b6c..3296fa8 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -9,8 +9,8 @@ from apns2.errors import exception_class_for_reason class NotificationPriority(Enum): - Immediate = 10 - Delayed = 5 + Immediate = '10' + Delayed = '5' class APNsClient(object): From 1c16d81e462cf49d05f6d2b9ac8126226ed4bf9e Mon Sep 17 00:00:00 2001 From: firkeuf Date: Fri, 13 May 2016 14:08:55 +0300 Subject: [PATCH 2/2] Update client.py should add force_proto else get proto = None and crash hyper/http20/connection.py", line 354 assert proto in H2_NPN_PROTOCOLS or proto == H2C_PROTOCOL --- apns2/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apns2/client.py b/apns2/client.py index 3296fa8..d0dd8ea 100644 --- a/apns2/client.py +++ b/apns2/client.py @@ -14,12 +14,12 @@ class NotificationPriority(Enum): class APNsClient(object): - def __init__(self, cert_file, use_sandbox=False, use_alternative_port=False): + def __init__(self, cert_file, use_sandbox=False, use_alternative_port=False, proto=None): server = 'api.development.push.apple.com' if use_sandbox else 'api.push.apple.com' port = 2197 if use_alternative_port else 443 ssl_context = init_context() 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, force_proto=proto or 'h2') def send_notification(self, token_hex, notification, priority=NotificationPriority.Immediate, topic=None): json_payload = dumps(notification.dict(), ensure_ascii=False, separators=(',', ':')).encode('utf-8')