This differential starts CommIOSNotifications implementation by introducing notifications handlers that emit relevant JavaScript events and register them in NotificationCenter. All implementation here is copeied from Ashoats fork of RN notifications.
Details
Build the app
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Is there a more idiomatic way we can pass events, without directly using RCTBridge? See here for the old way. I can't see if TurboModule have a different mechanism for dispatching events, but might be worth reviewing that as well.
I have just tested subclassing RCTEventEmitter and it worked correctly. It will even simplify some JS code in further diffs. I should update this diff stack shortly , so that CommIOSNotifications implements RCTEventEmitter.
Question
native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm | ||
---|---|---|
41 ↗ | (On Diff #20495) | If this gets called at the start of the application, then how do we already have localNotification set? |
native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm | ||
---|---|---|
41 ↗ | (On Diff #20495) | This is explained here: https://developer.apple.com/documentation/uikit/uiapplicationlaunchoptionslocalnotificationkey. If the app was launched by the system as a reaction for local notification, it is present in launchOptions. |
Observe NSNotificationCenter from the beggining, not when the first JavaScript listener is added.
Sorry, read through this a bit more critically and have a couple more comments...
native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm | ||
---|---|---|
24–27 ↗ | (On Diff #20689) | Why not specify this on the .h file? |
133 ↗ | (On Diff #20689) | Reverse conditions to reduce indentation and to exit early |
135 ↗ | (On Diff #20689) | What's the point of this lazy initialization? |
- Consequently use dot syntax
- Remove event handlers that are redundant since no JS code subscribes those events.
- Implement notification parsing in Objective C, so that we don't have to do the parsing in JS and use exact and simple types for notifications.
native/ios/Comm/CommIOSNotifications/CommIOSNotifications.mm | ||
---|---|---|
148–158 ↗ | (On Diff #21007) | Since we deprecated managedAps in codeVersion 135, there is no point to continuing to support it in this code |