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

feat: temporarily allow aps data via registration message #896

Merged
merged 1 commit into from
May 15, 2017
Merged
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
2 changes: 1 addition & 1 deletion autopush/router/apnsrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _route(self, notification, router_data):
payload["cryptokey"] = notification.headers["crypto_key"]
elif "encryption_key" in notification.headers:
payload["enckey"] = notification.headers["encryption_key"]
payload['aps'] = {"content-available": 1}
payload['aps'] = router_data.get('aps', {"content-available": 1})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an aps entry, then content-available doesn't need to be present?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
There needs to be an "aps" block, thus why I default to "{content-available": 1}, however, 'content-available is equivalent to our silent notifications, so it can be problematic. I presume that the folks providing the override aps data are knowledgeable and allow for full customization.

apns_id = str(uuid.uuid4()).lower()
try:
apns_client.send(router_token=router_token, payload=payload,
Expand Down
8 changes: 8 additions & 0 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ def test_register(self):
self.router.register("uaid", router_data=router_data, app_id="firefox")
eq_(router_data, {"rel_channel": "firefox", "token": "connect_data"})

def test_extended_register(self):
router_data = {"token": "connect_data",
"aps": {"foo": "bar",
"gorp": "baz"}}
self.router.register("uaid", router_data=router_data, app_id="firefox")
eq_(router_data, {"rel_channel": "firefox", "token": "connect_data",
"aps": {"foo": "bar", "gorp": "baz"}})

def test_register_bad(self):
with assert_raises(RouterException):
self.router.register("uaid", router_data={}, app_id="firefox")
Expand Down