| slug | android-sdk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| feature | integration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| archetype | integration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sdk_min_version | 3.7.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sdk_artifact | iterableapi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title | Iterable's Android SDK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source_url | https://support.iterable.com/hc/articles/360035019712 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source_repo | Iterable/iterable-docs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source_path | docs/developer-and-api-docs/iterables-ios-and-android-sdks/android-sdk/index.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source_ref | 16ae7f4a908f84d6eb15fe6f5390f07cc5afe20d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source_sha | c0ebe8b736d334190bc4fcae820fa386642aa40d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetched_at | 2026-05-25 15:11:39 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| polished_at | 2026-06-05 13:59:18 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| layer | a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| snippets |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| summary | This article describes how to install and configure Iterable's [Android SDK](https://github.com/Iterable/iterable-android-sdk). |
This article describes how to install and configure Iterable's Android SDK.
Iterable's Android SDK supports Android versions 5.0 (API level 21) and higher.
Depending on your minSdkVersion, Iterable's Android SDK can encrypt some
data at rest. For more information, read Upgrading to 3.4.10+.
Follow these steps to install Iterable's Android SDK. If you're upgrading from a previous version, see Upgrading the SDK.
Warning
If your app targets API level 22 or lower, read Upgrading to 3.4.10+ to learn about some adjustments you'll need to make to your Android project.
Before installing Iterable's Android SDK in your mobile app, tell your Iterable project about your mobile app.
To do this, follow the instructions in Setting up Android Push Notifications, which describe how to:
-
Define a mobile app in your Iterable project.
-
Give that app a push integration. A push integration stores configuration and authentication information Iterable can use to send push notifications to your app.
Even if you don't want to send push notifications, Iterable can use your app's push integration to send silent push notifications, to tell your app that Iterable has new in-app and embedded messages for it to fetch and display.
To make calls to Iterable's's API, the SDK needs a mobile API key. To learn how to create one, read API Keys
Warning
Never embed server-side API keys in client-side code (whether JavaScript, a mobile application or otherwise), since they can be used to access all of your project's data.
For a mobile app, use a mobile API key. For additional security, enable JWT authentication, if you can support it.
If necessary, you can use different API keys for debug and production builds of your app.
Tip
To determine the latest version of Iterable's Android SDK, see search.maven.org.
To use Iterable's Android SDK in your app, add the SDK and Firebase Messaging as
dependencies to your application's build.gradle:
dependencies{
implementation 'com.iterable:iterableapi:3.5.3'
// Optional, contains Inbox UI components:
implementation 'com.iterable:iterableapi-ui:3.5.3'
// Version 17.4.0+ is required for push notifications and in-app message features:
implementation 'com.google.firebase:firebase-messaging:X.X.X'
}If you're using ProGuard when building your Android app, add this line of ProGuard configuration to your build:
-keep class org.json.** { *; }
To learn how to do this, check out Android's guide: Shrink, obfuscate, and optimize your app.
Warning
If you use ProGuard but skip this step, some SDK features may not work as expected.
To initialize Iterable's Android SDK, create an IterableConfig and set its
various configuration options.
Do this when your application is starting up, usually in the onCreate method
of your Application class. Then, pass this IterableConfig to IterableApi.initialize,
along with your API key.
IterableConfig config = new IterableConfig.Builder().build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);IterableConfig contains various configuration options for the SDK. For
more information, refer to the following sections of this document. Or, take
a look at the IterableConfig source code.
Warning
- Version 3.4.10 of Iterable's Android SDK provides a configuration option to store in-app messages in memory, rather than in a local file. For more information, read Encrypted data.
- Don't
initializethe SDK in theonCreatemethod of anActivity. Instead, do it when your app is starting up, regardless of whether it has been launched to open an activity or in the background, as the result of an incoming push notification.
To prevent application not responding (ANR) errors during app startup when using
SDKs that need to initialize on background, initialize the SDK asynchronously
instead of using the standard initialize() method. For example:
// In Application.onCreate()
IterableApi.initializeInBackground(this, "<YOUR_API_KEY>", config) {
// SDK is ready - this callback is optional
}To subscribe to initialization completion from multiple places:
IterableApi.onSDKInitialized {
// This callback will be invoked when initialization completes
// If already initialized, it's called immediately
}Background initialization prevents ANRs by:
- Running all initialization work on a background thread.
- Automatically queuing API calls until initialization completes.
- Ensuring that no data is lost during startup.
- Providing callbacks on the main thread when ready.
Warning
Always wait for initialization to complete before you access SDK internals. Then, to ensure that the SDK is ready for use, use the callback methods provided above.
If your Iterable project is hosted on Iterable's European data center (EDC),
update your IterableConfig to use Iterable's EDC-based API endpoints:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setDataRegion(IterableDataRegion.EU).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);Starting with version 3.4.0
of Iterable's Android SDK, you'll need to declare the specific URL protocols
that the SDK can expect to see on incoming links (and that it should handle
as needed). This prevents the SDK from opening links that use unexpected
URL protocols.
To do this, pass the protocols you'd like the SDK to support (as an array of
strings) to the setAllowedProtocols method on IterableConfig.Builder.
For example, this code allows the SDK to handle http://, tel://, and mycompany://
links:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setAllowedProtocols(new String[]{"http", "tel", "mycompany"}).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);Warning
Iterable's Android SDK handles https, action, itbl, and iterable links,
regardless of the contents of this array. However, you must explicitly declare any
other types of URL protocols you'd like the SDK to handle (otherwise, the SDK
won't open them in the web browser or as deep links).
By default, Iterable's Android SDK stores in-app messages in an unencrypted local
file. If you'd prefer to have SDK store in-app messages in memory instead, use the
setUseInMemoryStorageForInApps(true) SDK configuration option (defaults to false):
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setUseInMemoryStorageForInApps(true).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);For more information about this option, read Upgrading to 3.4.10+.
In Step 1: Define a mobile app and push integration in Iterable, you defined a mobile app in Iterable, and you gave it a push integration.
Every push integration in Iterable has a name, and that name almost always matches
your Android app's package name (for example, com.example.app). By default,
this is what the SDK expects: to find a push integration in your Iterable project
with a name that matches your app's package name.
Tip
To find the name of your app's push integration in Iterable, navigate to Settings > Apps and Websites, open the mobile app associated with your app, find the Push section, and look at the Name column in the row associated with your push integration.
However, push integrations created in Iterable before August of 2019 can have
custom names. If this is the case for your push integration, tell the SDK the name
of your push integration by calling setPushIntegrationName on
IterableConfig:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setPushIntegrationName(“<PUSH_INTEGRATION_NAME>“).build();
IterableApi.initialize(context, “<YOUR_API_KEY>“, config);If you're using a JWT-enabled API Key, you'll need custom code to manage JWT tokens for the signed-in user.
When initializing the SDK, provide an auth handler. The SDK uses the auth handler to:
- Fetch new JWT tokens from your server.
- Report when a non-null JWT token has been retrieved.
- Report when there have been failures fetching new JWT tokens.
The object that you pass to the SDK as an auth manager must implement the
IterableAuthManager interface:
public interface IterableAuthHandler {
String onAuthTokenRequested();
void onTokenRegistrationSuccessful(String authToken);
void onAuthFailure(AuthFailure authFailure);
}For example:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setAuthHandler(new IterableAuthHandler() {
@Override
public String onAuthTokenRequested() {
// Fetch a JWT token for the signed-in user, from your server, and
// return it to the SDK.
return "<JWT_TOKEN_FOR_THE_CURRENT_USER>";
}
@Override
public void onTokenRegistrationSuccessful(String authToken) {
// The SDK has retrieved a non-null JWT token for the signed-in user.
// However, the SDK does not validate the token before calling this
// method.
}
@Override
public void onAuthFailure(AuthFailure authFailure) {
// Inspect the authFailure enum constant and take any necessary action. For
// example, you can pause auth retries (see section 5.5.3, below).
}
}).build();
IterableApi.initialize(_context, "<YOUR_API_KEY>", config);onAuthTokenRequested
The SDK calls onAuthTokenRequested when it needs a new JWT token for the
signed-in user. This method should fetch a new JWT token from your server and
return it to the SDK as a string.
This method is called when:
- You identify a user by calling
setEmailorsetUserId. - You update a user's email address by calling
updateEmail. - The current JWT token has expired, or is about to expire.
- The SDK receives a JWT-related
401response from Iterable's API.
onTokenRegistrationSuccessful
The SDK calls onTokenRegistrationSuccessful after onAuthTokenRequested
returns a non-null JWT token. However, other than a null check, the SDK does not
validate the token before calling this method. Generally, you won't need to
implement this method.
onAuthFailure
The SDK calls onAuthFailure after it fails to fetch a new JWT token for the
signed-in user. The AuthFailure object passed to this method describes the
reason for the failure, along with other information.
This method is called when:
onAuthTokenRequestedreturnsnull.onAuthTokenRequestedthrows an exception.- The SDK receives a JWT-related
401response from Iterable's API. - The token returned by
onAuthTokenRequestedis invalid.
In onAuthFailure, to determine the reason for the failure, inspect the
AuthFailure object, which has these properties:
userKey- A string that identifies the user byuserIdoremail.failedAuthToken- The JWT token that caused the failure.failedRequestTime- The timestamp of the failed request, if applicable.failureReason- AnAuthFailureReasonenum constant that indicates the reason for the failure.
AuthFailureReason can have these values:
AUTH_TOKEN_EXPIRATION_INVALID– An auth token's expiration must be less than one year from its issued-at time.AUTH_TOKEN_EXPIRED– The token has expired.AUTH_TOKEN_FORMAT_INVALID– Token has an invalid format (failed a regular expression check).AUTH_TOKEN_GENERATION_ERROR–onAuthTokenRequestedthrew an exception.AUTH_TOKEN_GENERIC_ERROR– Any other error not captured by another constant.AUTH_TOKEN_INVALIDATED– Iterable has invalidated this token and it cannot be used.AUTH_TOKEN_NULL–onAuthTokenRequestedreturned a null JWT token.AUTH_TOKEN_PAYLOAD_INVALID– Iterable could not decode the token's payload (iat,exp,email, oruserId).AUTH_TOKEN_SIGNATURE_INVALID– Iterable could not validate the token's authenticity.AUTH_TOKEN_USER_KEY_INVALID– The token doesn't include anemailor auserId. Or, one of these values is included, but it references a user that isn't in the Iterable project.AUTH_TOKEN_MISSING– The request to Iterable's API did not include a JWT authorization header.
Tip
You can also provide a JWT token for the current user by passing it directly to
setEmail or setUserId.
To specify how long before the expiration of the user's current JWT token
the SDK should call your auth token refresh handler,
to fetch a new token, call setExpiringAuthTokenRefreshPeriod on IterableConfig:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setExpiringAuthTokenRefreshPeriod(time_in_seconds).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);To control how the SDK handles consecutive JWT token refresh attempts, specify an auth retry policy. An auth retry policy allows you to control:
- The number of consecutive times the SDK should attempt to refresh a user's JWT token, in between successful API calls, before giving up.
- The interval between those attempts.
- A backoff strategy.
// When creating a RetryPolicy object, specify a maximum number of retries, an
// interval between retries, and a backoff strategy: RetryPolicy.Type.LINEAR or
// RetryPolicy.Type.EXPONENTIAL. The SDK's default RetryPolicy has a maximum of
// 10 retries, an interval of 6 seconds, and a linear backoff strategy.
RetryPolicy retryPolicy = new RetryPolicy(10, 10, RetryPolicy.Type.LINEAR);
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setAuthRetryPolicy(time_in_seconds).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);After the SDK reaches the maximum number of consecutive JWT-related request failures,
as configured by your RetryPolicy, it stops attempting to refresh the JWT token.
Tip
Auto-retry for offline processing (3.7.0+)
In addition to the RetryPolicy above (which controls JWT refresh scheduling),
the SDK supports automatic retry for offline-queued tasks that fail due to JWT
expiration. When enabled via remote configuration, the offline task runner
pauses authenticated tasks on a 401 error, refreshes the JWT, and retries
automatically. Unauthenticated API calls continue processing while
authentication is paused. This feature requires no code changes.
It's also possible to manually pause JWT token refresh attempts. To do this, call:
IterableApi.getInstance().pauseAuthRetries(true);When JWT refresh attempts have been paused, they'll only resume after:
- You provide a new JWT token to the SDK, by calling
setAuthToken. - You identify the user by calling
setEmailorsetUserId. - You update the user's email by calling
updateEmail - The app restarts.
- You manually pause and unpause JWT token refresh attempts, by calling:
// If you didn't manually pause JWT refresh attempts in the first place, // first call pauseAuthRetries(true). Then, call pauseAuthRetries(false). IterableApi.getInstance().pauseAuthRetries(true); IterableApi.getInstance().pauseAuthRetries(false);
In Android apps with minSdkVersion 23 or higher (Android 6.0)
Iterable's Android SDK encrypts sensitive user data when storing it in the
keychain. This includes the user's email, userId, and authToken (JWT).
This encryption is enabled by default. However, if you need to disable it, you
can do so by setting the keychainEncryption option to false when
initializing the SDK:
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setKeychainEncryption(false).build(); // Disable encryption for keychain storage
IterableApi.initialize(context, apiKey, config);If your in-app or inbox messages load external resources (such as custom fonts or stylesheets) and you're seeing CORS errors, configure a base URL for the WebView.
By default, the WebView sends a blank origin when requesting resources. If your server's CORS policy rejects blank origins, set the base URL to match whatever origin your server accepts (such as your CDN domain, app domain, or https://app.iterable.com).
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setWebViewBaseUrl("https://app.iterable.com") // Use https://app.eu.iterable.com for EU
.build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);When you know the user's email or userId, identify them by calling:
IterableApi.getInstance().setEmail("user@example.com");IterableApi.getInstance().setUserId("userId");
Note
- Make sure to identify the user after you've specified the configuration
options on
IterableConfig, as described in Step 5: Set SDK configuration options. - Don't set an email and user ID in the same session.
- If you've prefetched a JWT auth token, you can pass it directly to
setEmailandsetUserId(useful to work around race conditions that can sometimes occur).
Next, configure the SDK to handle push notifications.
Tip
If the name of your app's push integration, in Iterable, differs from your
app's package name (they usually match), make sure to specify your push
integration name on IterableConfig. To learn how to do this, read
Step 5.5: Specify a push integration name, if necessary.
Every user + device + app combination can be identified by a unique push token, which is stored on the user's profile in Iterable. Iterable users this token to send push notifications to the user.
The SDK automatically saves a push token to the user's profile whenever you
call setEmail or setUserId.
However, you can also handle this token registration manually:
-
When initializing the SDK, disable automatic push token registration by calling
setAutoPushRegistration(false)onIterableConfig. -
Whenever it makes sense, save a device token for the signed-in user to Iterable by calling
registerForPushonIterableApi:IterableApi.getInstance().registerForPush();
Note
- Device registration fails when no
emailoruserIdhas been set. - If you're calling
setEmailorsetUserIdafter the app has already launched (for example, when a new user logs in), callregisterForPushto register the device for the current user.
The SDK automatically adds a FirebaseMessagingService to the app manifest. To
handle incoming push notifications, no extra setup is necessary.
However, if your application implements its own FirebaseMessagingService:
- Forward
onMessageReceivedcalls toIterableFirebaseMessagingService.handleMessageReceived. - Forward
onNewTokencalls toIterableFirebaseMessagingService.handleTokenRefresh.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
IterableFirebaseMessagingService.handleMessageReceived(this, remoteMessage);
}
@Override
public void onNewToken(String s) {
IterableFirebaseMessagingService.handleTokenRefresh();
}
}Note
- This step is mandatory for working with multiple push providers.
- Firebase has deprecated
FirebaseInstanceIdService. It has been replaced withonNewToken. - To handle silent push notifications, use a custom
FirebaseMessagingService.
To learn how to use Iterable's Android SDK with Embedded Messaging, read Embedded Messages with Iterable's Android SDK.
This section describes how to upgrade from earlier versions of Iterable's Android SDK.
-
Supported Android versions: Beginning with version 3.5.12, Iterable's Android SDK supports Android versions 5.0 (API level 21) and higher.
-
Disabling encryption: By default, encryption is enabled to securely store sensitive user data. To disable keychain encryption, set the
setKeychainEncryptionoption tofalsewhen initializing the SDK:IterableConfig config = new IterableConfig.Builder() .setKeychainEncryption(false) // Disable encryption for keychain storage .build(); IterableApi.initialize(context, apiKey, config);
Starting with version 3.5.3, Iterable's Android SDK provides more insight into JWT refresh failures, to help you take appropriate action in your application code.
When a JWT refresh fails (for any of various reasons), the SDK calls
onAuthFailure(AuthFailure authFailure) on the IterableAuthHandler instance
you provided to the SDK at initialization. The AuthFailure object provides
more information about the failure.
onAuthFailure(AuthFailure authFailure) replaces onTokenRegistrationFailed(Throwable object).
If you've implemented that method, you'll need to update your application code.
For more information, see Step 5.6.1: Register an auth handler.
When upgrading to version 3.5.2+
of the SDK, you can make use of the setAuthRetryPolicy method on IterableConfig
to specify:
- The maximum number of consecutive JWT-related request failures the SDK should allow before giving up, Defaults to 10.
- The interval between each retry attempt. Defaults to 6 seconds.
- A backoff strategy: linear or exponential. Defaults to linear.
In Android apps with minSdkVersion 23 or higher (Android 6.0)
Iterable's Android SDK now encrypts the following fields when storing them at
rest:
email— The user's email address.userId— The user's ID.authToken— The JWT used to authenticate the user with Iterable's API.
(Note that Iterable's Android SDK does not store the last push payload at rest—before or after this update.)
For more information about this encryption in Iterable's Android SDK, examine
the source code for IterableKeychain,
a file in Iterable's Android SDK.
This release also allows you to have your Android apps (regardless of minSdkVersion)
store in-app messages in memory, rather than in an unencrypted local file.
However, an unencrypted local file is still the default option.
To store in-app messages in memory, set the setUseInMemoryStorageForInApps(true)
SDK configuration option (defaults to false):
IterableConfig config = new IterableConfig.Builder()
// ... other configuration options ...
.setUseInMemoryStorageForInApps(true).build();
IterableApi.initialize(context, "<YOUR_API_KEY>", config);When users upgrade to a version of your Android app that uses this version of
the SDK (or higher), and you've set this configuration option to true, the
local file used for in-app message storage (if it already exists) is deleted
However, no data is lost.
If your app targets API level 23 or higher, this is a standard SDK upgrade, with no special instructions.
If your app targets an API level less than 23, you'll need to make the following changes to your project (which allow your app to build, even though it won't encrypt data):
-
In
AndroidManifest.xml, add<uses-sdk tools:overrideLibrary="androidx.security" /> -
In your app's
app/build.gradle:- Add
multiDexEnabled trueto thedefaultobject, underandroid. - Add
implementation androidx.multidex:multidex:2.0.1to thedependencies.
- Add
-
Starting with version
3.4.0of Iterable's Android SDK, you'll need to declare the URL protocols that the SDK should expect to see on incoming links (and then handle as needed). For more information, read about Step 5.3: Set allowed URL protocols, above. -
Version 3.4.0 changes two static methods on the
IterableApiclass,handleAppLinkandgetAndTrackDeepLink, to instance methods. To call these methods, you'll need to first grab an instance of theIterableApiclass by callingIterableApi.getInstance(). For example,IterableApi.getInstance().handleAppLink(...).
To resolve a breaking change introduced in Firebase Cloud Messaging version 22.0.0, version 3.3.1 of Iterable's Android SDK bumps the minimum required version of its Firebase Android dependency to 20.3.0.
If upgrading to version 3.3.1 causes your app to crash on launch, or your build
to fail, add the following lines to your app's build.gradle file:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}Versions 3.2.0+ of the SDK depend on the AndroidX support libraries. To use these versions, you'll need to migrate your app to use AndroidX.
-
In-app messages
-
spawnInAppNotificationThe
spawnInAppNotificationmethod is no longer needed and will fail to compile. The SDK now displays in-app messages automatically. There is no need to poll the server for new messages. -
Handling manually
To control when in-app messages display (rather than displaying them automatically), set
IterableConfig.inAppHandler(anIterableInAppHandlerobject). From itsonNewInAppmethod, returnInAppResponse.SKIP.To get the queue of available in-app messages, call
IterableApi.getInstance().getInAppManager().getMessages(). Then, callIterableApi.getInstance().getInAppManager().showMessage(message)to show a specific message. -
Custom actions
This version of the SDK reserves the
iterable://URL scheme for Iterable-defined actions handled by the SDK and theaction://URL scheme for custom actions handled by the mobile application's custom action handler.If you are currently using the
itbl://URL scheme for custom actions, the SDK will still pass these actions to the custom action handler. However, support for this URL scheme will eventually be removed (timeline TBD), so it is best to move templates to theaction://URL scheme as it's possible to do so.
-
-
Deep links
-
Consolidated deep link URL handling. By default, the SDK handles deep links with the the URL handler assigned to
IterableConfig. -
Checking if a URL is an Iterable deep link: To check if a URL is an Iterable deep link before handling it, use the
isIterableDeepLinkmethod:if (IterableApi.getInstance().isIterableDeepLink(urlString)) { // URL is an Iterable deep link }
This method returns
trueif the URL matches the Iterable deep link pattern (URLs containing/a/in the path). For more information, read Android App Links.
-
To migrate from GCM (Google Cloud Messaging) to Firebase (Firebase Cloud Messaging)
- Upgrade the existing Google Cloud project to Firebase.
- Update the server token in the existing GCM-based Iterable push integration, applying the new Firebase token.
- Update the Android app to support Firebase.
If you use the same project and integration name for Firebase Cloud Messaging, the old tokens remain valid and you won't need to re-register existing devices. If you're using a new project for Firebase Cloud Messaging, and have existing devices on a GCM project with a different sender ID:
- Updating the app will generate new tokens for users, but the old tokens remain valid.
- When migrating from one sender ID to another, when initializing Iterable's SDK,
specify
legacyGCMSenderIdonIterableConfig. This disables old tokens to make sure users won't receive duplicate notifications.
If you're having trouble installing or initializing the SDK, read Testing and Troubleshooting the Iterable SDK.