-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new APNs configuration option push_with_badge
to suppress sending aps.badge
in APNs messages.
#358
base: main
Are you sure you want to change the base?
Add a new APNs configuration option push_with_badge
to suppress sending aps.badge
in APNs messages.
#358
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a new APNs configuration option `push_with_badge` to suppress sending `aps.badge` in APNs messages. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ class ApnsPushkin(ConcurrencyLimitedPushkin): | |
"topic", | ||
"push_type", | ||
"convert_device_token_to_hex", | ||
"push_with_badge", | ||
} | ConcurrencyLimitedPushkin.UNDERSTOOD_CONFIG_FIELDS | ||
|
||
APNS_PUSH_TYPES = { | ||
|
@@ -555,14 +556,20 @@ def _get_payload_full( | |
if loc_args: | ||
payload["aps"].setdefault("alert", {})["loc-args"] = loc_args | ||
|
||
if badge is not None: | ||
if self.get_config("push_with_badge", bool, True) and badge is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than pulling this option value out of the config on each request, please do so in def __init__(self, name: str, sygnal: "Sygnal", config: Dict[str, Any]) -> None:
# ...
self.push_with_badge = self.get_config("push_with_badge", bool, True) def _get_payload_event_id_only(
self, n: Notification, default_payload: Dict[str, Any]
) -> Dict[str, Any]:
# ...
if self.push_with_badge and badge is not None: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 will be in the next commit |
||
payload["aps"]["badge"] = badge | ||
|
||
if loc_key and n.room_id: | ||
payload["room_id"] = n.room_id | ||
if loc_key and n.event_id: | ||
payload["event_id"] = n.event_id | ||
|
||
if not self.get_config("push_with_badge", bool, True): | ||
if n.counts.unread is not None: | ||
payload["unread_count"] = n.counts.unread | ||
if n.counts.missed_calls is not None: | ||
payload["missed_calls"] = n.counts.missed_calls | ||
|
||
return payload | ||
|
||
async def _send_notification( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some slight wording adjustments. You may also want to explain why this could be desirable when "not using
mutable-content
"?Though after writing this out, I feel like we're conflating two different behaviours in a single config option:
aps.badge
field.unread_count
andmissed_calls
fields.Could you say why you want the
unread_count
andmissed_calls
fields? Or even what the overall goal for this PR is with respect to your implementation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this comes off as a bit confusing.
The primary focus of this commit to suppress the
aps.badge
field so iOS does not automatically draw the badge on the home screen. In the event an iOS app is receiving APNS from multiple independent sources, the badge value is incorrect. Whether the other source is sending its ownaps.badge
or not, sygnal sending its ownaps.badge
still conflicts with the true badge value expected by the user.When suppressing that field, I wanted to ensure the underlying data was still available to the iOS client, so it could be used, if desired. The inclusion of the
unread_count
andmissed_calls
fields were to represent the expanded form of whataps.badge
represents here .I agree the inclusion of
unread_count
andmissed_calls
could become their own setting, but I was unsure about APNS message length assumptions.unread_count
andmissed_calls
in APNS would be reasonable (I can submit a separate PR). Then this PR would simply be about toggling the inclusion ofaps.badge
.