This repository was archived by the owner on Jul 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
Add a new APNs configuration option push_with_badge to suppress sending aps.badge in APNs messages.
#358
Open
cennis91
wants to merge
2
commits into
matrix-org:main
Choose a base branch
from
cennis91:push-with-badge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add a new APNs configuration option push_with_badge to suppress sending aps.badge in APNs messages.
#358
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
|
Member
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:
Author
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( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.badgefield.unread_countandmissed_callsfields.Could you say why you want the
unread_countandmissed_callsfields? 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.badgefield 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.badgeor not, sygnal sending its ownaps.badgestill 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_countandmissed_callsfields were to represent the expanded form of whataps.badgerepresents here .I agree the inclusion of
unread_countandmissed_callscould become their own setting, but I was unsure about APNS message length assumptions.unread_countandmissed_callsin APNS would be reasonable (I can submit a separate PR). Then this PR would simply be about toggling the inclusion ofaps.badge.