Skip to content

Commit

Permalink
Merge branch 'pr-topic' of https://github.com/zulip/aioapns
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Mar 17, 2024
2 parents aad9c27 + 2d69284 commit 5eb5955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions aioapns/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NotificationRequest:
"priority",
"collapse_key",
"push_type",
"apns_topic",
)

def __init__(
Expand All @@ -37,6 +38,8 @@ def __init__(
priority: Optional[int] = None,
collapse_key: Optional[str] = None,
push_type: Optional[PushType] = None,
*,
apns_topic: Optional[str] = None,
) -> None:
self.device_token = device_token
self.message = message
Expand All @@ -45,6 +48,7 @@ def __init__(
self.priority = priority
self.collapse_key = collapse_key
self.push_type = push_type
self.apns_topic = apns_topic


class NotificationResult:
Expand Down
6 changes: 5 additions & 1 deletion aioapns/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ async def send_notification(
(":path", "/3/device/%s" % request.device_token),
("host", self.APNS_SERVER),
("apns-id", request.notification_id),
("apns-topic", self.apns_topic),
]
if request.apns_topic is not None:
apns_topic = request.apns_topic
else:
apns_topic = self.apns_topic
headers.append(("apns-topic", apns_topic))
if request.time_to_live is not None:
expiration = int(time.time()) + request.time_to_live
headers.append(("apns-expiration", str(expiration)))
Expand Down

0 comments on commit 5eb5955

Please sign in to comment.