Skip to content

feat: add React Native New Architecture support (RN 0.83+ / Expo SDK 55)#44

Draft
mikemilla wants to merge 1 commit intomainfrom
cursor/new-architecture-support-97e0
Draft

feat: add React Native New Architecture support (RN 0.83+ / Expo SDK 55)#44
mikemilla wants to merge 1 commit intomainfrom
cursor/new-architecture-support-97e0

Conversation

@mikemilla
Copy link
Copy Markdown
Collaborator

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: Apply com.facebook.react plugin unconditionally (not gated behind newArchEnabled), so the library works when New Architecture is always enabled. Replaced the hardcoded com.facebook.react:react-android:0.73.7 dependency with a dynamic version (+) so the consumer's React Native version is used.
  • CourierReactNativePackage.kt: Migrated from ReactPackage to TurboReactPackage, implementing getModule() and getReactModuleInfoProvider() for proper Turbo Module discovery in New Architecture.
  • ReactNativeModule.kt: Replaced currentActivity as? ReactActivity with currentActivity as Activity?. In bridgeless mode, currentActivity may return a ComponentActivity rather than ReactActivity, making the old cast fail silently.
  • CourierClientModule.kt: Updated putUserToken to use the safer activity reference.
  • CourierSystemModule.kt: Updated registerPushNotificationClickedOnKilledState, requestNotificationPermission, and getNotificationPermissionStatus to use the safer activity reference.
  • CourierPreferencesViewManager.kt: Added null safety for currentActivity casting to FragmentActivity.
  • 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. The install_modules_dependencies helper (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 importing RCTBridge.h and using a string-based notification name for RCTBridgeWillReloadNotification (which doesn't exist in bridgeless mode).
  • CourierReactNative-Bridging-Header.h: Added conditional RCTBridge.h import for backward compatibility.
  • CourierSystemModule.swift: Added documentation comment about RCTBridgeWillReloadNotification behavior in bridgeless mode.

JavaScript

  • Modules.tsx: Updated module lookup to try TurboModuleRegistry first (New Architecture) with automatic fallback to NativeModules (bridge mode / interop layer). This ensures the library works in both architectures.

Compatibility

  • Old Architecture (RN < 0.83): Fully backward compatible. The interop layer and NativeModules fallback ensure existing apps continue to work.
  • New Architecture (RN 0.83+): Works via the interop layer with TurboReactPackage discovery. Native modules are automatically wrapped as Turbo Modules, and view managers are wrapped for Fabric compatibility.

Testing

  • All 125 unit tests pass
  • TypeScript compilation passes (0 errors)
  • ESLint passes (0 errors, only pre-existing warnings)
Open in Web Open in Cursor 

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support for React Native New Architecture (Expo SDK 55 / RN 0.83+)

2 participants