feat: [SDK-4157] add React Native New Architecture support (TurboModules)#1920
Conversation
|
@fadi-george how sure are we that this works well for us? with the entire architecture update |
Device support would be depedent on the Android SDK so still Android 6.0+ (API 24). |
8188d28 to
ee4d7c6
Compare
ee4d7c6 to
b043706
Compare
38f670e to
891680c
Compare
00a99db to
b34904c
Compare
5090bef to
cf81d92
Compare
We encountered an issue in our app related to the OneSignal integration. We were previously using version ^5.2.2, and after generating a new build, the app started crashing with the following error: TypeError: this.RNOneSignal.onPermissionChanged is not a function (it is undefined), js engine: hermes To resolve the issue, we had to pin the dependency to version 5.3.6, which restored the expected behavior. |
@burghausen8 Im looking into this old arch issue but if you use new arch, it should be fine. |
Description
One Line Summary
Migrate the SDK to React Native's New Architecture using TurboModules, Fabric, and Bridgeless Mode, dropping legacy Bridge support.
Details
Motivation
React Native 0.76+ enables the New Architecture by default. The SDK needed native TurboModule support to work correctly with apps using TurboModules, Fabric renderer, and Bridgeless Mode. This is tracked in #1675 and SDK-4157.
Implementation follows the official Turbo Native Modules guide from the React Native working group, including the event emitter pattern using
CodegenTypes.EventEmitter.Scope
This is a breaking change (v6.0.0). The minimum React Native version is now 0.76.0.
What changed:
NativeOneSignal.tsTurboModule spec with codegen configurationRNOneSignal.javaextends codegen-generatedNativeOneSignalSpec, package registration usesBaseReactPackage.mto.mm, module extendsNativeOneSignalSpecBase, implementsgetTurboModule:for JSI registrationNativeEventEmittertoCodegenTypes.EventEmitterwith directonXxxsubscriptions#ifdef RCT_NEW_ARCH_ENABLEDconditionals (legacy arch no longer supported)getPushSubscriptionId,getPushSubscriptionToken,getOptedIn,hasPermission)addTags,addAliases,addTriggers) now useRecord<string, string>typesglobalThisto prevent duplicate event subscriptionsWhat is not affected:
Testing
Unit testing
All 246 unit tests pass. Tests updated to mock
TurboModuleRegistryand codegen-generated event emitters instead ofNativeModulesandNativeEventEmitter.Manual testing
Tested on iOS simulator and Android emulator with the demo app covering initialization, push permission, notifications (foreground/background/click), login/logout, tags, aliases, email/SMS, IAM triggers, outcomes, and event observers.
cd into
examples/demoand run eitherbun run iosorbun run android.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is