feat: add React Native New Architecture support (RN 0.83+ / Expo SDK 55)#44
Draft
feat: add React Native New Architecture support (RN 0.83+ / Expo SDK 55)#44
Conversation
- Android: Apply com.facebook.react plugin unconditionally for New Architecture - Android: Replace hardcoded react-android dependency with dynamic version - Android: Migrate CourierReactNativePackage to TurboReactPackage for proper Turbo Module discovery - Android: Fix currentActivity null safety for bridgeless mode (replace ReactActivity casting with Activity) - Android: Fix CourierPreferencesViewManager null safety on currentActivity - Android: Update SDK versions (compileSdk/targetSdk 34, minSdk 24, Kotlin 1.9.24, NDK 26.1) - iOS: Update podspec with cleaner New Architecture configuration - iOS: Fix CourierReactNativeDelegate for bridgeless mode compatibility (conditional RCTBridge import, string-based notification name) - iOS: Add bridgeless mode documentation to notification observers - JS: Add TurboModuleRegistry support in Modules.tsx with NativeModules fallback for backward compatibility Closes #35
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.
Summary
Adds compatibility with React Native's New Architecture, which is mandatory starting with RN 0.83+ (Expo SDK 55). The library now works in both bridge mode (old architecture) and bridgeless mode (New Architecture) using the interop layer with proper Turbo Module discovery.
Closes #35
Changes
Android
build.gradle: Applycom.facebook.reactplugin unconditionally (not gated behindnewArchEnabled), so the library works when New Architecture is always enabled. Replaced the hardcodedcom.facebook.react:react-android:0.73.7dependency with a dynamic version (+) so the consumer's React Native version is used.CourierReactNativePackage.kt: Migrated fromReactPackagetoTurboReactPackage, implementinggetModule()andgetReactModuleInfoProvider()for proper Turbo Module discovery in New Architecture.ReactNativeModule.kt: ReplacedcurrentActivity as? ReactActivitywithcurrentActivity as Activity?. In bridgeless mode,currentActivitymay return aComponentActivityrather thanReactActivity, making the old cast fail silently.CourierClientModule.kt: UpdatedputUserTokento use the saferactivityreference.CourierSystemModule.kt: UpdatedregisterPushNotificationClickedOnKilledState,requestNotificationPermission, andgetNotificationPermissionStatusto use the saferactivityreference.CourierPreferencesViewManager.kt: Added null safety forcurrentActivitycasting toFragmentActivity.gradle.properties: Updated SDK versions (compileSdk/targetSdk 34, minSdk 24, Kotlin 1.9.24, NDK 26.1) for modern RN compatibility.iOS
courier-react-native.podspec: Cleaned up indentation in the New Architecture fallback block. Theinstall_modules_dependencieshelper (available in RN 0.71+) already handles both old and New Architecture setup automatically.CourierReactNativeDelegate.h: Changed#import "RCTAppDelegate.h"to#import <React/RCTAppDelegate.h>for proper module resolution.CourierReactNativeDelegate.m: Made bridgeless-mode safe by conditionally importingRCTBridge.hand using a string-based notification name forRCTBridgeWillReloadNotification(which doesn't exist in bridgeless mode).CourierReactNative-Bridging-Header.h: Added conditionalRCTBridge.himport for backward compatibility.CourierSystemModule.swift: Added documentation comment aboutRCTBridgeWillReloadNotificationbehavior in bridgeless mode.JavaScript
Modules.tsx: Updated module lookup to tryTurboModuleRegistryfirst (New Architecture) with automatic fallback toNativeModules(bridge mode / interop layer). This ensures the library works in both architectures.Compatibility
NativeModulesfallback ensure existing apps continue to work.TurboReactPackagediscovery. Native modules are automatically wrapped as Turbo Modules, and view managers are wrapped for Fabric compatibility.Testing