Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: APNs library requires parameters to be strings
Browse files Browse the repository at this point in the history
closes #797
  • Loading branch information
jrconlin committed Feb 6, 2017
1 parent d537fd8 commit 09335d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions autopush/router/apns2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
SANDBOX = 'api.development.push.apple.com'
SERVER = 'api.push.apple.com'

APNS_PRIORITY_IMMEDIATE = 10
APNS_PRIORITY_LOW = 5
APNS_PRIORITY_IMMEDIATE = '10'
APNS_PRIORITY_LOW = '5'
APNS_MAX_CONNECTIONS = 20


Expand Down Expand Up @@ -101,13 +101,14 @@ def send(self, router_token, payload, apns_id,
"""
body = json.dumps(payload)
priority = APNS_PRIORITY_IMMEDIATE if priority else APNS_PRIORITY_LOW
# NOTE: Hyper requires that all header values be strings.
headers = {
'apns-id': apns_id,
'apns-priority': priority,
'apns-priority': str(priority),
'apns-topic': topic or self.topic,
}
if exp:
headers['apns-expiration'] = exp
headers['apns-expiration'] = str(exp)
url = '/3/device/' + router_token
connection = self._get_connection()
try:
Expand Down
4 changes: 2 additions & 2 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ def test_route_low_priority_notification(self):
ok_(self.mock_connection.request.called)
body = self.mock_connection.request.call_args[1]
headers = body['headers']
eq_(headers, {'apns-expiration': exp,
eq_(headers, {'apns-expiration': str(exp),
'apns-topic': 'com.example.SomeApp',
'apns-priority': 5,
'apns-priority': '5',
'apns-id': 'apnsid'})

@inlineCallbacks
Expand Down

0 comments on commit 09335d5

Please sign in to comment.