Page MenuHomePhabricator

Use native modules to clear notifications for a given thread
ClosedPublic

Authored by marcin on Jan 11 2023, 4:48 AM.
Tags
None
Referenced Files
F3486143: D6228.id21265.diff
Wed, Dec 18, 3:23 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Unknown Object (File)
Sat, Dec 14, 3:50 AM
Subscribers

Details

Summary

This differential calls native api to remove all active notifications for a given thread without using additional persistence layer from redux.

Test Plan

Add logging statement to native implementation of removeAllActiveNotificationsForThread. Build the app, put it in background. Send several notifications ensure they are present in notification center. Open the app, enter the thread notifications were sent for. Ensure they disappear and
the are logged.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Use directly in push handler not in reducer

Bring back necessary if statement

native/push/push-handler.react.js
300 ↗(On Diff #20789)

Let's avoid directly accessing NativeModules, and instead introduce a file that handles the interaction with NativeModules, and call that file from here (same as iOS)

native/push/push-handler.react.js
300 ↗(On Diff #20789)

Sure. I will probably use android.js file for that.

Move NativeModules access to separate file

native/push/android.js
16 ↗(On Diff #20919)

I'm surprised Flow is okay with this!! What does it report the type of CommAndroidNotifications is? We probably need to explicitly type it, eg. like we type AndroidLifecycleModule in native/lifecycle/lifecycle-module.js

ashoat requested changes to this revision.Jan 13 2023, 6:30 AM

Requesting changes for types, but let me know if there's some codegen magic already generating them or something

This revision now requires changes to proceed.Jan 13 2023, 6:30 AM
native/push/android.js
16 ↗(On Diff #20919)

What does it report the type of CommAndroidNotifications is?

It reports the type is any and the type of NativeModules is { [moduleName: string]: any }

native/push/android.js
16 ↗(On Diff #20919)

Ah yeah, we need to type this (and the iOS one)

Type CommAndroidNotifications

Please address comment before landing

native/push/android.js
17 ↗(On Diff #20977)

Is there anything else on NativeModules.CommAndroidNotifications? I think yes... if so, we should type it so

This revision is now accepted and ready to land.Jan 16 2023, 7:28 PM
native/push/android.js
17 ↗(On Diff #20977)

Currently no, but I will expand the scope of this type as I will be gradually adding differentials that replace subsequent react-native-firebase methods.

native/push/android.js
17 ↗(On Diff #20977)

I am skeptical that there are no default methods on the native module, eg. getConstants. Can you modify your Test Plan to include confirming that there is only one method? You can do that via JS debugger with a debugger breakpoint, or possibly with some kind of console.log (might need to log the prototype or something though).

Looks ok, but please make sure the types are correct.

native/push/push-handler.react.js
287–297 ↗(On Diff #20977)

It seems like we can have similar api for both platforms. Basically, we could have a method removeAllActiveNotificationsForThread implemented in a file with platform specific extension.

Inexact type for native module