-
Notifications
You must be signed in to change notification settings - Fork 33
MOB-11639 Background Initialization #946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
35c5798
0d5267c
b1111ad
1bc2507
f56eb7f
577ac00
956046b
8d7f6b1
1558f1a
528cf13
3cca277
5d8b26e
51e00f4
82a6246
1d76339
05bc53e
26303d5
d9ff956
4533d2c
c69d901
b149237
32d3f8d
44f8730
4db9ffd
d57929e
b02d594
98b45f5
2f1c646
66d3e0c
3bacaac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| } | ||
| ``` | ||
|
|
||
| **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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought that - |
||
| ``` | ||
|
|
||
| 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: | ||
|
|
||
Large diffs are not rendered by default.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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