Enable encrypted notification coalescing in NSE on iOS
Summary:
This differential enables NSE to perform coalescing of encrypted notifications. Previously notification coalescing was done by setting apns-collapse-id header in notification. This header was then equal to the identifier property of UNNotificationRequest (object received by the NSE on each mutable notification): https://developer.apple.com/documentation/usernotifications/unnotificationrequest/1649634-identifier?language=objc. The OS automatically replaces previous notification with the latest notification with the same request identifier property. In the world of encrypted notification this header cannot be set anymore. It would be a security breach since apple would see two encrypted notifications sharing the same collapse id. Unfortunately it is not possible to modify identifier property of UNNotificationRequest in the NSE. This forces us to:
- put collapseID in the encrypted payload.
- after decryption check for this field.
- If found then we have to create local notification with the same contents as the original one and request identifier equal to collapse id.
- Display local notification and silence the original one by calling content handler with blank notification content ([[UNNotificationContent alloc] init])
This is implemented in this diff.
Test Plan:
Impossible to test without some changes on the keyserver.
- Build iOS app
- Apply this patch: https://gist.github.com/marcinwasowicz/a318bb475e575df662429702905b4a01
- Send a couple of photos to the same user, or update some chat settings a couple of times (the same setting!).
- Ensure that coalescing takes place.
Reviewers: tomek, atul, bartek
Reviewed By: tomek
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D9144