Add configurable notification content for FCM v1 pushkins#432
Add configurable notification content for FCM v1 pushkins#432wcjord wants to merge 1 commit intoelement-hq:mainfrom
Conversation
Add an opt-in `include_notification_content` config option for GCM/FCM v1 pushkins. When enabled, a visible `notification` payload is injected into FCM v1 requests with: - title: room_name > sender_display_name > sender > "New Message" - body: content.body or "New Message" Data-only FCM messages are throttled/dropped by iOS in the background, causing unreliable push delivery. Including a visible notification payload ensures immediate display on iOS devices. Addresses element-hq#366. Signed-off-by: wcjord <32568597+wcjord@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in configuration flag to the FCM v1 (GCM) pushkin to inject a visible message.notification payload derived from Sygnal’s push data, improving reliability of iOS delivery for background scenarios.
Changes:
- Introduces
include_notification_contentconfig option for FCM v1 pushkins and uses it to addmessage.notification.title/body. - Adds unit tests covering enabled behavior, title fallback, and the default-disabled behavior.
- Adds a changelog entry documenting the new opt-in feature.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
sygnal/gcmpushkin.py |
Adds the include_notification_content config and injects an FCM v1 message.notification payload derived from message data. |
tests/test_gcm.py |
Adds coverage for the new opt-in notification content behavior and default behavior. |
changelog.d/gcm-notification-content.feature |
Documents the new feature and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| body["message"]["notification"] = { | ||
| "title": title, | ||
| "body": notification_body, | ||
| } | ||
|
|
anoadragon453
left a comment
There was a problem hiding this comment.
(Most apps use the event_id_only format these days for privacy, so I'm just going to focus on that use case. Shout if your use case makes use of the full event body!)
I believe how this is supposed to work is the iOS app will define a default_payload in the data dictionary which includes the fields it would like to appear in the notification.
For instance, ElementX iOS sets the following for default_payload:
"default_payload": {
"aps": {
"mutable-content": 1,
"alert": {"loc-key": "Notification", "loc-args": []}
}
}
aps.alert.loc-{key,args} allow for an app to define localisable strings. This means that apps for non-English markets can have local generic message translations, instead of "New Message".
This payload is then merged into the payload sent to APNs:
Lines 388 to 420 in 4c7439a
I would expect the FCM pusher to do a similar thing - taking the default_payload into account. That's in contrast to this PR, which just sets body.message.notification to hard-coded English terms (when event_id_only format is used).
We advise iOS applications to set default_payload in our application documentation.
There was a problem hiding this comment.
This file should be renamed to 432.feature.
Summary
Data-only FCM messages are throttled/dropped by iOS in the background, causing unreliable push delivery. This adds an opt-in
include_notification_contentconfig option for GCM/FCM v1 pushkins that injects a visiblenotificationpayload into FCM v1 requests, ensuring immediate display on iOS devices.Addresses #366.
Changes
When
include_notification_content: trueis set in the pushkin config:room_name>sender_display_name>sender>"New Message"content.bodyor"New Message"The notification payload is only added for FCM v1 API requests (not legacy GCM). When disabled (the default), behavior is unchanged.
New config option
Tests
test_include_notification_content_api_v1— verifies title/body from push datatest_include_notification_content_fallback_title— verifies fallback when room_name/sender_display_name absenttest_notification_content_disabled_by_default— verifies no notification key when config absentChangelog
changelog.d/gcm-notification-content.featureincluded.Signed-off-by: wcjord 32568597+wcjord@users.noreply.github.com