Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@ To learn more about various SDK features, read:
- [Embedded Messages with Iterable's Android SDK](https://support.iterable.com/hc/articles/23061877893652)
- [Unknown User Activation: Developer Docs](https://support.iterable.com/hc/sections/40078809116180)

## Background Initialization (Recommended)

To prevent ANRs during app startup, use background initialization instead of the standard `initialize()` method:

```kotlin
// In Application.onCreate()
IterableApi.initializeInBackground(this, "your-api-key", config) {
// SDK is ready - this callback is optional
}
```
Comment on lines +46 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callback should go in the method parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is some kind of new kotlin syntax that seems to compile


**For subscribing to initialization completion from multiple places:**

```kotlin
IterableApi.onSDKInitialized {
// This callback will be invoked when initialization completes
// If already initialized, it's called immediately
}
Comment on lines +54 to +57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought that - onSDKInitialized may be redundant considering that initializeInBackground() {
// This call back gets called only after initialization. Or if there are failure scenario, perhaps an object may be sent here as well to indicate how the initialization went.
}

```

Background initialization prevents ANRs by:
- Running all initialization work on a background thread
- Automatically queuing API calls until initialization completes
- Ensuring no data is lost during startup
- Providing callbacks on the main thread when ready

**⚠️ Important:** Always wait for initialization completion before accessing SDK internals. Accessing the SDK internals before initialization completes can cause crashes. Use the callback methods above to ensure the SDK is ready before use.

## Sample projects

For sample code, take a look at:
Expand Down
216 changes: 169 additions & 47 deletions iterableapi/src/main/java/com/iterable/iterableapi/IterableApi.java

Large diffs are not rendered by default.

Loading
Loading