feat: add React Native New Architecture support (Turbo Modules + Fabric interop)#48
Draft
feat: add React Native New Architecture support (Turbo Modules + Fabric interop)#48
Conversation
…ic interop) Addresses #35: Support for React Native New Architecture (Expo SDK 55 / RN 0.83+) Changes: - Use TurboModuleRegistry with NativeModules fallback for module resolution so native modules are discoverable in both bridgeless and bridge modes - Fix currentActivity null safety: avoid casting to ReactActivity which may not exist in bridgeless mode; use Activity directly - Fix CourierClientModule: use reactApplicationContext for CourierDevice.current() instead of force-unwrapping reactActivity - Fix CourierPreferencesViewManager: safe-cast currentActivity to FragmentActivity with fallback to ThemedReactContext - Update react-android dependency to use dynamic version (+) so the consuming app's RN version is resolved automatically - Update default SDK versions (compileSdk/targetSdk 34, minSdk 24, Kotlin 1.9.24) - Add safeExtGet helper for SDK version resolution from consuming project iOS side already supports New Architecture through the interop layer: - install_modules_dependencies in podspec handles both architectures - RCTEventEmitter/RCTViewManager work through Fabric/TurboModule interop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35
Summary
Adds support for React Native New Architecture (Expo SDK 55 / RN 0.83+) where bridgeless mode is always enabled. The library now works through the Turbo Module and Fabric interop layers while maintaining backward compatibility with older RN versions.
Changes
JavaScript / TypeScript
src/Modules.tsx: Native modules are now resolved throughTurboModuleRegistryfirst, falling back toNativeModulesfor backward compatibility. This ensures modules are discoverable in both bridgeless (New Architecture) and bridge (Old Architecture) modes.Android
ReactNativeModule.kt: ReplacedReactActivitycast with directActivityreference. In bridgeless mode,currentActivitymay not be aReactActivity, so casting to it would returnnulland break functionality.CourierClientModule.kt: Fixed a dangerousreactActivity!!force-unwrap inputUserToken(). Now usesreactApplicationContextforCourierDevice.current(), which is always available regardless of architecture mode.CourierSystemModule.kt: Updated allreactActivityreferences to use the safeactivityaccessor (returningActivity?). Permission requests and notification checks now work correctly in bridgeless mode.CourierPreferencesViewManager.kt: Fixed unsafecurrentActivity as FragmentActivitycast that would crash in bridgeless mode. Now safely falls back toThemedReactContextwhenFragmentActivityis unavailable.build.gradle:react-androiddependency from hardcoded0.73.7to dynamic+so the consuming app's RN version is resolved automaticallysafeExtGethelper so consuming apps can override SDK versions throughrootProject.extgradle.properties: Updated default SDK versions tocompileSdk 34,targetSdk 34,minSdk 24, Kotlin1.9.24for compatibility with modern RN versions.iOS
The iOS side already supports New Architecture through the interop layer:
install_modules_dependenciesin the podspec handles both architecture dependenciesRCTEventEmitterandRCTViewManagersubclasses work through Fabric/TurboModule interop automaticallyCompatibility
NativeModulesfallbackTurboModuleRegistryTurboModuleRegistry+ interopTesting