Skip to content

Conversation

@mrehan27
Copy link
Contributor

@mrehan27 mrehan27 commented Dec 1, 2025

part of: MBL-1476, MBL-1477

Summary

Removes legacy event listener methods (addListener, removeListeners) from React Native SDK, helping complete the cleanup of support for old architecture. This simplifies the codebase and improves alignment with new architecture (TurboModules + Fabric).

Changes

  • Removed NativeEventEmitter fallback from customerio-inapp.ts and native-logger-listener.ts
  • Removed addListener and removeListeners from TurboModule specs
  • Removed corresponding method implementations in NativeCustomerIOLoggingModule and NativeMessagingInAppModule
  • Converted ReactInAppEventListener to use a singleton pattern with lazy initialization (ReactInAppEventListener.shared) for better compatibility with Expo's plugin setup
  • Updated all references to use ReactInAppEventListener.shared singleton instance
  • Removed ABI specific logging checks for armeabi/armeabi-v7a as the crash was fixed in React Native core and these workarounds are no longer necessary

PR Stack:


Note

Remove old-architecture event listener support and fallbacks, adopt a singleton in-app event listener, and simplify Android logging/messaging modules and TurboModule specs.

  • Android (In-App Messaging)
    • ReactInAppEventListener converted to a lazy singleton (instance), updated usage in NativeMessagingInAppModuleImpl and NativeMessagingInAppModule.
    • Event emission streamlined to cache emitter and early-return when absent.
  • Android (Logging)
    • Removed ABI-specific checks and legacy listener stubs; simplified init/teardown with try-catch and direct setLogEventEmitter wiring.
  • JS/TS
    • Removed NativeEventEmitter fallbacks and old-arch listener methods; listeners now use TurboModule events only with guarded registration and a no-op subscription fallback on failure.
  • TurboModule Specs
    • Dropped addListener/removeListeners from NativeCustomerIOLogging and NativeCustomerIOMessagingInApp; specs expose only onCioLogEvent/onInAppEventReceived and dismissMessage.

Written by Cursor Bugbot for commit d01b4b7. This will update automatically on new commits. Configure here.

@mrehan27 mrehan27 self-assigned this Dec 1, 2025
@mrehan27 mrehan27 requested a review from a team as a code owner December 1, 2025 14:05
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


  • iOS APN: 546.3.0 (29440159)
  • iOS FCM: 546.3.0 (29440159)
  • Android APN: 546.3.0 (29440159)

private val inAppMessagingModule: ModuleMessagingInApp?
get() = kotlin.runCatching { CustomerIO.instance().inAppMessaging() }.getOrNull()
val inAppEventListener = ReactInAppEventListener()
val inAppEventListener = ReactInAppEventListener.shared
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we will be removing NativeMessagingInAppModuleImpl with removal of old arch support in next PR, we'll now be accessing singleton instance using ReactInAppEventListener.shared in both React Native SDK and Expo Plugin. Expo plugin will require an update after this change though but won't be breaking for customers as Expo Plugin is now fixed to one React Native SDK version.

Build.SUPPORTED_ABIS?.firstOrNull()
?.lowercase()
?.contains("armeabi") == true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job cleaning this up!

@mahmoud-elmorabea mahmoud-elmorabea requested a review from a team December 22, 2025 09:33
Copy link
Contributor

@mahmoud-elmorabea mahmoud-elmorabea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 💯 Thanks for accommodating suggestions 😇

@mahmoud-elmorabea mahmoud-elmorabea requested a review from a team December 22, 2025 13:16
@mrehan27 mrehan27 merged commit 7540a6a into feature/react-native-0-83 Dec 22, 2025
16 checks passed
@mrehan27 mrehan27 deleted the mbl-1476-ts-cleanup branch December 22, 2025 20:23
const eventEmitter = new NativeEventEmitter(native);
return eventEmitter.addListener(InAppEventListenerEventName, emitter);
// Return a no-op subscription to maintain backwards compatibility
return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If new-arch is now mandatory, can we throw an explicit error here so customers know they must enable TurboModules? otherwise it would be silent failures for them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apps using old arch won't compile so the failure wouldn't be silent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On old architecture:
- First call: onCioLogEvent() throws → logs warning → sets isInitialized = true
- Subsequent calls: Early return at line 23 prevents any retry

Once marked initialized, the system never attempts to reconnect, is this the intent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old arch is removed in next PRs in stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants