Page MenuHomePhabricator

Implement parsing notification received when application is foregrounded into object that can be directly passed to JavaScript. Implement relevant broadcast receiver as well
ClosedPublic

Authored by marcin on Jan 16 2023, 5:44 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:54 AM
Unknown Object (File)
Mon, May 13, 1:52 AM
Subscribers

Details

Summary

This differential implements function that parses data received in CommNotificationsHandler when application is in the foreground into object that directly maps to what we expect to receive on the JavaScript side to display foreground notification. Relevant broadcast receiver is implemented
as well.

Test Plan

Build the app. Temporarily make parsing method as public static and call it in CommNotificationsHandler on RemoteMessage instance. App must not crash.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek requested changes to this revision.Jan 18 2023, 9:16 AM
tomek added inline comments.
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
61 ↗(On Diff #20973)

This shouldn't be a part of CommAndroidNotificationsEventEmitter - can we include this in CommAndroidNotificationsForegroundMessageReceiver?

66 ↗(On Diff #20973)

We can probably avoid this flag by early returning.

68–78 ↗(On Diff #20973)

We can avoid repeatedly creating these arrays by making a static final consts with them. Also, if we want true immutability, we should avoid using arrays and instead use e.g. Set.of.

80–87 ↗(On Diff #20973)

Is this code really correct? Intuitively we should say that dataComplete = true when all the obligatoryKeys are present and not when any of them is present.

94–97 ↗(On Diff #20973)

Just a nit, but we can avoid calling the same method twice

125 ↗(On Diff #20973)

Could you bring back the newline?

This revision now requires changes to proceed.Jan 18 2023, 9:16 AM
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
61 ↗(On Diff #20973)

This method will be moved to CommAndroidNotifications module and exposed as public static.It will be needed in CommAndroidNotifications to implement getInitialNotification method. Alternatively it is possible to create separate file with class RemoteMessageParser that exposes this method as public. We can't include this in CommAndroidNotificationsForegroundMessageReceiver since it will be needed in other places.

  1. Move parsing method to separate class.
  2. Apply refactoring changes requested by tomek
tomek added inline comments.
native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationParser.java
10 ↗(On Diff #21248)

A good convention is to write const names using uppercase letters

45 ↗(On Diff #21248)

Please add a newline

native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsEventEmitter.java
61 ↗(On Diff #20973)

Making it a separate class was a good idea

This revision is now accepted and ready to land.Jan 26 2023, 1:48 AM

Add newline. NAme constants in capitals.