diff --git a/autopush/router/apns2.py b/autopush/router/apns2.py index 85905f1f..1ccae889 100644 --- a/autopush/router/apns2.py +++ b/autopush/router/apns2.py @@ -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 @@ -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: diff --git a/autopush/tests/test_router.py b/autopush/tests/test_router.py index d7f65e39..dce99fea 100644 --- a/autopush/tests/test_router.py +++ b/autopush/tests/test_router.py @@ -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