Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Unreleased

### Fixes
- [#793] Fixed `IterableApi` unresolved reference in `MainApplication.kt` when using
new architecture (RN 0.76+, Expo 52). The SDK now automatically calls
`IterableApi.setContext()` during module initialization, so users no longer need
to add this call manually in their Android application code.

## 2.2.0

### Updates
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ Notes:
- Ensure your app is configured for New Architecture per the React Native docs.
- The example app in this repository is configured with New Architecture enabled.

### Android Setup (RN 0.76+ / New Architecture)

Starting with version 2.2.1, the SDK **automatically** calls `IterableApi.setContext()`
when the React Native module is initialized. You no longer need to manually add
`IterableApi.setContext(this)` in your `MainApplication.kt` or `MainActivity.kt`.

If you are upgrading from an older version, you can safely **remove** the following
from your Android code:

```kotlin
// No longer needed - remove this import
import com.iterable.iterableapi.IterableApi

// No longer needed - remove this call
IterableApi.setContext(this)
```

The SDK's initialization (via JavaScript/TypeScript `Iterable.initialize()`) handles
all necessary Android context setup automatically.

> **Note for Expo users (SDK 52+):** No additional native Android configuration is
> required beyond installing the package. The SDK handles context initialization
> automatically through autolinking.

## Beta Versions

To opt into beta versions of the SDK, you can install the latest beta version by using the `beta` tag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.iterable.iterableapi.IterableApi;

public class RNIterableAPIPackage extends BaseReactPackage {
@Nullable
@Override
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
if (RNIterableAPIModuleImpl.NAME.equals(name)) {
// Automatically set the context so users don't need to call
// IterableApi.setContext() manually from MainApplication or MainActivity.
// This resolves issues with IterableApi being unresolvable in
// MainApplication.kt when using the new architecture (RN 0.76+).
IterableApi.setContext(reactContext.getApplicationContext());
return new RNIterableAPIModule(reactContext);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.iterable.iterableapi.IterableApi

class MainActivity : ReactActivity() {

Expand All @@ -28,7 +27,6 @@ class MainActivity : ReactActivity() {
* This being in Kotlin **may** cause issues with react-native-screens
*/
override fun onCreate(savedInstanceState: Bundle?) {
IterableApi.setContext(this)
// Call super.onCreate with null to prevent savedInstanceState restoration issues
super.onCreate(null)
}
Expand Down
Loading