The context for this change is described here: https://linear.app/comm/issue/ENG-4453#comment-4d1770b3. We introduce dummy body to the encrypted notification to make sure we comply to apple docs. Additionally we make necessary changes to
NotificationService extension to prevent from displaying notification that contains ENCRYPTED text.
Details
Build release iOS app. Ensure that notifications, rescinds and bade-only notifications work correctly
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Create mutable content directly
native/ios/NotificationService/NotificationService.mm | ||
---|---|---|
167 ↗ | (On Diff #29058) | In current setup badge-only notifications and only badge-only notifications carry threadID property so this check is semantically correct. IF the solution proposed in this diff appears to solve the issue we will introduce badgeOnly field to iOS notifications along with other refactors. |
native/ios/NotificationService/NotificationService.mm | ||
---|---|---|
63 ↗ | (On Diff #29064) | Signal also seems to create notification content from scratch so it is probably safe: https://github.com/signalapp/Signal-iOS/blob/main/SignalNSE/NSEEnvironment.swift#L164 |
keyserver/src/push/crypto.js | ||
---|---|---|
69 ↗ | (On Diff #29064) | In general, I think we should opt for >= here. That way, the releaser can simply replace NEXT_CODE_VERSION with the version they are releasing |
keyserver/flow-typed/npm/@parse/node-apn_vx.x.x.js | ||
---|---|---|
41 ↗ | (On Diff #29064) |
|
keyserver/src/push/crypto.js | ||
72 ↗ | (On Diff #29064) |
|
(Resigning since encrypted notifications are a blindspot for me, feel free to re-add if there's something specific I can be useful for)
keyserver/flow-typed/npm/@parse/node-apn_vx.x.x.js | ||
---|---|---|
41 ↗ | (On Diff #29064) | My theory, as described and discussed in https://linear.app/comm/issue/ENG-4453/notifs-are-broken-in-production#comment-eaa12167, is that encrypted notifs don't trigger NSE since they have pushType: alert and mutable-content: 1 but don't have the alert field. According to apple docs alert field can be either string or a dict, that can contain may different keys. So logically to test my theory we don't have to modify this type and just put some string under alert field. However I came across this doc: https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications?language=objc, where Apple considers the case of encrypted notification handled in NSE. In their example they configure notification payload to have a dict in alert field with body set to string. Therefore I intuitively decided to match apple tutorial as close as possible. To do this I had to modify this type.
When alert is a dict it can have a lot of different keys. I didn't add them all since this diff is just to make a test release. If it proves to work I will refactor this type to cover all keys that alert field can accept. However if you think we should do this now, then please re-request changes and I will add those keys to this type. |
keyserver/src/push/crypto.js | ||
72 ↗ | (On Diff #29064) | aps is always set for apn.Notification. Most of setter methods of this class put data in aps under the hood. |
keyserver/src/push/crypto.js | ||
---|---|---|
69 ↗ | (On Diff #29542) | This can't be landed on master, since we only want these changes to apply to staff releases. You'll likely need a % 2 check here |
native/ios/NotificationService/NotificationService.mm | ||
---|---|---|
62–68 ↗ | (On Diff #29943) | Just confirming – this change is safe to land for public-facing production builds, right? |
native/ios/NotificationService/NotificationService.mm | ||
---|---|---|
62–68 ↗ | (On Diff #29943) | Yes - this change is safe for public releases however hiding it behind isStaffRelease check would result in the same behaviour. After landing this stack staff users will receive encrypted badgeonly notifications with ENCRYPTED alert body. Therefore we must create new notification content without body but with badge count. Public users will be still receiving badgeonly notifications without any body so it would be sage not to enter this code and call contentHandler directly on what has arrived with didReceive.. callback. |