Open lisa-bella97 opened 9 months ago
Hi @lisa-bella97, @cortinico .
the listeners chain is invoked in ComponentActivity Layer,
@CallSuper
@Override
protected void onNewIntent(
@SuppressLint({"UnknownNullness", "MissingNullability"}) Intent intent
) {
super.onNewIntent(intent);
for (Consumer<Intent> listener : mOnNewIntentListeners) {
listener.accept(intent);
}
}
React Native ReactActivity not always call super.OnNewIntent(..)
public void onNewIntent(Intent intent) {
if (!this.mDelegate.onNewIntent(intent)) {
super.onNewIntent(intent);
}
}
And the delegate condition is:
public boolean onNewIntent(Intent intent) {
if (!ReactFeatureFlags.enableBridgelessArchitecture && this.getReactNativeHost().hasInstance()) {
this.getReactNativeHost().getReactInstanceManager().onNewIntent(intent);
return true;
} else {
return false;
}
}
Maybe you can evaluate the usage of an ActivityEventListener (part of React Native framework) in a native module to handle your onNewIntent case
Description
My Android React Native app uses a foreground dispatch system to handle NFC intents. I have implemented the Activity.onNewIntent callback to process the data from the scanned NFC tag. I also used OnNewIntentListener registration via the addOnNewIntentListener method. This listener should get a callback associated with Activity.onNewIntent with the new Intent, but it does not - when I attach an NFC tag, Activity.onNewIntent is called as expected, but the OnNewIntentListener callback is not called. Native Android application (without React Native Framework) works as expected in this case.
Steps to reproduce
npm run android
.adb logcat | grep "MY_LOGS"
in terminal).Expected logs (containing OnNewIntentListener callback - handleNfcIntent):
React Native Version
0.73.2
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/lisa-bella97/reproducer-react-native
Screenshots and Videos
No response