File tree Expand file tree Collapse file tree
android/src/main/java/com/iterable/reactnative
example/android/app/src/main/java/iterable/reactnativesdk/example Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## Unreleased
2+
3+ ### Fixes
4+ - [ #793 ] Fixed ` IterableApi ` unresolved reference in ` MainApplication.kt ` when using
5+ new architecture (RN 0.76+, Expo 52). The SDK now automatically calls
6+ ` IterableApi.setContext() ` during module initialization, so users no longer need
7+ to add this call manually in their Android application code.
8+
19## 2.2.0
210
311### Updates
Original file line number Diff line number Diff line change @@ -76,6 +76,30 @@ Notes:
7676- Ensure your app is configured for New Architecture per the React Native docs.
7777- The example app in this repository is configured with New Architecture enabled.
7878
79+ # ## Android Setup (RN 0.76+ / New Architecture)
80+
81+ Starting with version 2.2 .1 , the SDK ** automatically** calls ` IterableApi.setContext()`
82+ when the React Native module is initialized. You no longer need to manually add
83+ ` IterableApi.setContext(this)` in your ` MainApplication.kt` or ` MainActivity.kt` .
84+
85+ If you are upgrading from an older version, you can safely ** remove** the following
86+ from your Android code:
87+
88+ ` ` ` kotlin
89+ // No longer needed - remove this import
90+ import com.iterable.iterableapi.IterableApi
91+
92+ // No longer needed - remove this call
93+ IterableApi.setContext(this)
94+ ` ` `
95+
96+ The SDK ' s initialization (via JavaScript/TypeScript `Iterable.initialize()`) handles
97+ all necessary Android context setup automatically.
98+
99+ > **Note for Expo users (SDK 52+):** No additional native Android configuration is
100+ > required beyond installing the package. The SDK handles context initialization
101+ > automatically through autolinking.
102+
79103## Beta Versions
80104
81105To opt into beta versions of the SDK, you can install the latest beta version by using the `beta` tag:
Original file line number Diff line number Diff line change 1010import com .facebook .react .bridge .ReactApplicationContext ;
1111import com .facebook .react .module .model .ReactModuleInfo ;
1212import com .facebook .react .module .model .ReactModuleInfoProvider ;
13+ import com .iterable .iterableapi .IterableApi ;
1314
1415public class RNIterableAPIPackage extends BaseReactPackage {
1516 @ Nullable
1617 @ Override
1718 public NativeModule getModule (@ NonNull String name , @ NonNull ReactApplicationContext reactContext ) {
1819 if (RNIterableAPIModuleImpl .NAME .equals (name )) {
20+ // Automatically set the context so users don't need to call
21+ // IterableApi.setContext() manually from MainApplication or MainActivity.
22+ // This resolves issues with IterableApi being unresolvable in
23+ // MainApplication.kt when using the new architecture (RN 0.76+).
24+ IterableApi .setContext (reactContext .getApplicationContext ());
1925 return new RNIterableAPIModule (reactContext );
2026 } else {
2127 return null ;
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import com.facebook.react.ReactActivity
66import com.facebook.react.ReactActivityDelegate
77import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
88import com.facebook.react.defaults.DefaultReactActivityDelegate
9- import com.iterable.iterableapi.IterableApi
109
1110class MainActivity : ReactActivity () {
1211
@@ -28,7 +27,6 @@ class MainActivity : ReactActivity() {
2827 * This being in Kotlin **may** cause issues with react-native-screens
2928 */
3029 override fun onCreate (savedInstanceState : Bundle ? ) {
31- IterableApi .setContext(this )
3230 // Call super.onCreate with null to prevent savedInstanceState restoration issues
3331 super .onCreate(null )
3432 }
You can’t perform that action at this time.
0 commit comments