Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions gobiko/apns/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from collections import namedtuple
from contextlib import closing
from hyper import HTTP20Connection
from httpx import Client

from .exceptions import (
InternalException,
Expand Down Expand Up @@ -130,7 +130,7 @@ def _get_token(self):
return token

def _create_connection(self):
return HTTP20Connection(self.host, force_proto=self.force_proto)
return Client(http2=True)

def _create_token(self):
token = jwt.encode(
Expand Down Expand Up @@ -232,16 +232,14 @@ def _send_message(self, registration_id, alert,
return response

def _send_push_request(self, connection, registration_id, json_data, request_headers):
connection.request(
'POST',
'/3/device/{0}'.format(registration_id),
json_data,
response = connection.post(
f'https://{self.host}/3/device/{registration_id}',
data=json_data,
headers=request_headers
)
response = connection.get_response()

if response.status != APNSResponse.Success:
body = json.loads(response.read().decode('utf-8'))
if response.status_code != APNSResponse.Success:
body = response.json()
reason = body.get("reason")

if reason:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cryptography==3.4.2
hyper==0.7.0
httpx[http2]==0.18.1
PyJWT==2.0.1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
url = 'https://github.com/genesluder/python-apns',
download_url = 'https://github.com/genesluder/python-apns/tarball/0.1.6',
keywords = [
'apns',
'apns',
'push notifications',
],
classifiers = [],
install_requires=[
'cryptography<=3.3.2',
'hyper',
'httpx[http2]',
'pyjwt',
],
)