Page MenuHomePhabricator

Start CommIOSNotifications implementation by adding JavaScript events handlers.
ClosedPublic

Authored by marcin on Dec 28 2022, 4:41 AM.
Tags
None
Referenced Files
F3490299: D6066.diff
Wed, Dec 18, 3:44 PM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Unknown Object (File)
Sat, Dec 14, 4:14 AM
Subscribers

Details

Summary

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.

Test Plan

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.

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.

Implement CommIOSNotifications as RCTEventEmitter

tomek added a reviewer: ashoat.

Seems reasonable, but I'm really far from being an expert.

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?

ashoat requested changes to this revision.Jan 3 2023, 10:40 AM

Hmm, appears to be some bug in Phabricator where I can't Request Changes

This revision now requires changes to proceed.Jan 3 2023, 10:40 AM
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.

Thanks for explaining

This revision is now accepted and ready to land.Jan 4 2023, 5:45 PM
ashoat requested changes to this revision.Jan 9 2023, 9:56 AM

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?

This revision now requires changes to proceed.Jan 9 2023, 9:56 AM
  1. Consequently use dot syntax
  2. Remove event handlers that are redundant since no JS code subscribes those events.
  3. 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.
This revision is now accepted and ready to land.Jan 17 2023, 7:16 AM
ashoat requested changes to this revision.Jan 17 2023, 1:55 PM
ashoat added inline comments.
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

This revision now requires changes to proceed.Jan 17 2023, 1:55 PM
This revision is now accepted and ready to land.Jan 18 2023, 6:24 PM