@iterable/react-native-sdk - v4.0.0
    Preparing search index...

    Class IterableConfig

    An IterableConfig object sets various properties of the SDK.

    An IterableConfig object is passed into the static initialize method on the Iterable class when initializing the SDK.

    Index

    Constructors

    Properties

    allowedProtocols: string[] = []

    Use this array to declare the specific URL protocols that the SDK can expect to see on incoming links from Iterable, so it knows that it can safely handle them as needed. This array helps prevent the SDK from opening links that use unexpected URL protocols.

    To allow the SDK to handle http, tel, and custom links, use code similar to this:

    const config = new IterableConfig();
    config.allowedProtocols = ["http", "tel", "custom"];

    IMPORTANT: Iterable's React Native 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).

    androidSdkUseInMemoryStorageForInApps: boolean = false

    DEPRECATED - please use useInMemoryStorageForInApps as a replacement for this config option.

    NOTE: until this option is removed, it will still function with useInMemoryStorageForInApps by doing an OR operation, so if either this or useInMemoryStorageForInApps are set to true, the native Android SDK layer will use in memory storage for in-apps.

    This specifies the useInMemoryStorageForInApps config option downstream to the Android SDK layer.

    androidWakeDelayMs: number = 1000

    Delay (in milliseconds) the SDK waits on Android before invoking the URL handler after a deep-link event.

    On Android, the host Activity may still be waking from the background when a deep-link event is delivered. This delay gives the activity time to resume before the SDK dispatches the URL to urlHandler. Without it, the handler can race the activity lifecycle and drop or mishandle the link on cold start.

    The wake delay is applied only on Android; iOS dispatches immediately.

    Tune this value if your app observes dropped or duplicated deep links on Android. Increase it on slower devices or custom application classes; set it to 0 to dispatch synchronously (not recommended unless you have confirmed your activity lifecycle does not require the delay).

    const config = new IterableConfig();
    config.androidWakeDelayMs = 1500; // wait 1.5s on slow Android devices
    Iterable.initialize('<YOUR_API_KEY>', config);
    authCallbackTimeoutMs: number = 6000

    Maximum time (in milliseconds) the SDK waits for a native auth success or failure event before resolving the auth callback latch on its own.

    When authHandler returns an IterableAuthResponse, the SDK passes the authToken to the native layer and waits for either a handleAuthSuccessCalled or handleAuthFailureCalled event before invoking successCallback / failureCallback. This timeout is a safety net: if no native event arrives within the window, the SDK resolves the latch with a "no callback received" outcome and logs a warning rather than hanging the auth flow indefinitely.

    The timer is a fallback, not the primary resolution mechanism. The latch resolves immediately when the native event arrives.

    The default (6000) is chosen to comfortably exceed a typical mobile auth round-trip (the native layer performs passAlongAuthToken plus a full HTTP round-trip to the Iterable backend, which routinely exceeds 1 s on real networks) while staying well below the native auth latch ceiling of 30 s on both iOS and Android. Setting it below typical round-trip latency causes the safety net to win the race and drop the late native successCallback / failureCallback; setting it too high increases perceived auth latency only when the native layer fails to respond.

    const config = new IterableConfig();
    config.authCallbackTimeoutMs = 10000; // allow up to 10s for slow networks
    Iterable.initialize('<YOUR_API_KEY>', config);
    authHandler?: () => Promise<string | IterableAuthResponse | null | undefined>

    A function expression that provides a valid JWT for the app's current user to Iterable's React Native SDK.

    Provide an implementation for this method only if your app uses a JWT-enabled API key.

    Type Declaration

      • (): Promise<string | IterableAuthResponse | null | undefined>
      • Returns Promise<string | IterableAuthResponse | null | undefined>

        A promise that resolves to an IterableAuthResponse, a string, null, or undefined.

    To make requests to Iterable's API using a JWT-enabled API key, you should first fetch a valid JWT for your app's current user from your own server, which must generate it. The authHandler provides this JWT to Iterable's React Native SDK, which can then append the JWT to subsequent API requests. The SDK automatically calls authHandler at various times:

    • When your app sets the user's email or user ID.
    • When your app updates the user's email.
    • Before the current JWT expires (at a configurable interval set by expiringAuthTokenRefreshPeriod)
    • When your app receives a 401 response from Iterable's API with a InvalidJwtPayload error code. However, if the SDK receives a second consecutive 401 with an InvalidJwtPayload error when it makes a request with the new token, it won't call the authHandler again until you call setEmail or setUserId without passing in an auth token.

    TIP: The setEmail and setUserId mobile SDK methods accept an optional, prefetched auth token. If you encounter SDK errors related to auth token requests, try using this parameter.

    For more information about JWT-enabled API keys, read JWT-Enabled API Keys.

    This example demonstrates how an app that uses a JWT-enabled API key might initialize the SDK.

    const config = new IterableConfig();

    config.authHandler = () => {
    // ... Fetch a JWT from your server, or locate one you've already retrieved
    return new Promise(function (resolve, reject) {
    // Resolve the promise with a valid auth token for the current user
    resolve("<AUTH_TOKEN>")
    });
    };
    config.autoPushRegistration = false;

    Iterable.initialize('<YOUR_API_KEY>', config);
    autoPushRegistration: boolean = true

    When set to true (which is the default value), IterableSDK will automatically register and deregister notification tokens when you provide email or userId values to the SDK using Iterable.setEmail or Iterable.setUserId.

    checkForDeferredDeeplink: boolean = false

    When set to true, it will check for deferred deep links on first time app launch after installation from the App Store.

    This is currently deprecated and will be removed in the future.

    customActionHandler?: (
        action: IterableAction,
        context: IterableActionContext,
    ) => boolean

    A function expression used to handle action:// URLs for in-app buttons and links.

    Use this method to determine whether or not the app can handle the clicked custom action URL. If it can, it should handle the action and return true. Otherwise, it should return false.

    Type Declaration

    A custom action URL has format action://customActionName: an action:// prefix, followed by a custom action name. Decide with your marketing team on a set of known custom actions your app should support.

    WARNING: Earlier versions of the SDK used the itbl:// prefix for custom action URLs. The SDK still supports these custom actions, but they are deprecated and will not be supported forever. Migrate to action:// as it's possible to do so.

    This example responds to the action://achievedPremierStatus custom action URL by updating the app's styles and return true. Since this is the only custom action handled by the method, it returns false for anything else.

     const config = new IterableConfig();
    config.customActionHandler = (action, context) => {
    if (action.type == "achievedPremierStatus") {
    // For this action, update the app's styles
    this.updateAppStyles("premier");
    return true;
    }
    return false;
    }
    Iterable.initialize('<YOUR_API_KEY>', config);
    dataRegion: IterableDataRegion = IterableDataRegion.US

    This specifies the data region which determines the data center and associated endpoints used by the SDK

    decryptionFailureHandler?: (failure: IterableDecryptionFailure) => void

    A callback invoked when the Android SDK fails to decrypt PII in keychain storage. Before calling this handler, the native SDK clears stored PII, disables encryption for the device, and requires the user to sign in again.

    Android only. iOS does not surface decryption failures this way; setting this callback on iOS has no effect.

    Type Declaration

    const config = new IterableConfig();
    config.decryptionFailureHandler = (failure) => {
    console.error('Iterable decryption failed:', failure.message);
    // Prompt the user to log in again
    };
    enableEmbeddedMessaging: boolean = false

    Should the SDK enable and use embedded messaging?

    Documentation

    enableForegroundCriteriaFetch: boolean = true

    When true (the default), the SDK fetches unknown-user (anonymous) targeting criteria when the app enters the foreground.

    Set to false to disable that foreground fetch.

    enableUnknownUserActivation: boolean = false

    When true, the native SDK may store and process events for unidentified (unknown) users. Defaults to false.

    Visitor consent via Iterable.setVisitorUsageTracked is also required before the native SDK stores unknown-user events or runs unknown-user flows.

    encryptionEnforced: boolean = false

    Has no effect on any platform. Use IterableConfig.keychainEncryption.

    eventThresholdLimit: number = 100

    Maximum number of unknown-user (anonymous) events stored locally before identification. The native SDK drops the oldest events when the count exceeds this limit.

    The value is sent to the native SDK at init. The limit applies only while unknown-user activation is enabled (enableUnknownUserActivation) and visitor consent has been granted.

    expiringAuthTokenRefreshPeriod: number = 60.0

    The number of seconds before the current JWT's expiration that the SDK should call the authHandler to get an updated JWT.

    identityResolution: IterableIdentityResolution = ...

    Default identity-resolution behavior when identifying a user with Iterable.setEmail or Iterable.setUserId.

    Applies when unknown-user activation and visitor tracking are enabled on the native SDK. Omitted keys in a partial object default to true.

    inAppDisplayInterval: number = 30.0

    Number of seconds between each in-app message when displaying multiple in-app messages in sequence.

    Defaults to 30 seconds.

    inAppHandler?: (message: IterableInAppMessage) => IterableInAppShowResponse

    Implement this callback to override default in-app behavior.

    By default, every single in-app will be shown as soon as it is available. If more than 1 in-app is available, we show the first.

    Type Declaration

    Implement this property to override default in-app message behavior. For example, you might use the custom payload associated with an incoming message to choose whether or not to display it, or you might inspect the priorityLevel property to determine the message's priority.

    config.inAppHandler = (message: IterableInAppMessage) => {
    return message?.read ? IterableInAppShowResponse.skip : IterableInAppShowResponse.show;
    }
    keychainEncryption: boolean = true

    Android only: whether Iterable encrypts PII (email, userId, auth token) in on-device keychain storage. When true (the default), data is encrypted; when false, it is stored in plaintext. iOS always uses the system Keychain and ignores this option.

    logLevel: IterableLogLevel = IterableLogLevel.debug

    Set the verbosity of Android and iOS project's log system.

    By default, you will be able to see info level logs printed in IDE when running the app.

    logReactNativeSdkCalls: boolean = true

    Set whether the React Native SDK should print function calls to console.

    This is for calls within the React Native layer, and is separate from logLevel which affects the Android and iOS native SDKs

    onEmbeddedMessageUpdate?: () => void

    A callback function that is called when embedded messages are updated.

    This callback is triggered when the local cache of embedded messages changes, such as when new messages arrive or existing messages are removed.

    const config = new IterableConfig();
    config.onEmbeddedMessageUpdate = () => {
    console.log('Embedded messages updated!');
    // Refresh your UI to display the latest messages
    };
    Iterable.initialize('<YOUR_API_KEY>', config);
    onEmbeddedMessagingDisabled?: () => void

    A callback function that is called when embedded messaging is disabled.

    This callback is triggered when embedded messaging becomes unavailable, which can happen due to configuration issues or API errors.

    const config = new IterableConfig();
    config.onEmbeddedMessagingDisabled = () => {
    console.warn('Embedded messaging has been disabled');
    // Hide embedded message UI or show error state
    };
    Iterable.initialize('<YOUR_API_KEY>', config);
    onEmbeddedMessagingSyncFailed?: (reason: string | null) => void

    A callback function that is called when an embedded messaging sync fails.

    Type Declaration

      • (reason: string | null): void
      • Parameters

        • reason: string | null

          Failure reason from the native SDK, or null when none is available.

        Returns void

    const config = new IterableConfig();
    config.enableEmbeddedMessaging = true;
    config.onEmbeddedMessagingSyncFailed = (reason) => {
    console.warn('Embedded sync failed', reason);
    };
    Iterable.initialize('<YOUR_API_KEY>', config);
    onEmbeddedMessagingSyncSucceeded?: () => void

    A callback function that is called when an embedded messaging sync completes successfully.

    This is distinct from onEmbeddedMessageUpdate, which fires when the local embedded message cache changes. Sync success indicates the network sync operation finished without error.

    const config = new IterableConfig();
    config.enableEmbeddedMessaging = true;
    config.onEmbeddedMessagingSyncSucceeded = () => {
    console.log('Embedded sync succeeded');
    };
    Iterable.initialize('<YOUR_API_KEY>', config);
    onJwtError?: (authFailure: IterableAuthFailure) => void

    A callback function that is called when the SDK encounters an error while validing the JWT.

    The retry for JWT should be automatically handled by the native SDK, so this is just for logging/transparency purposes.

    Type Declaration

    const config = new IterableConfig();
    config.onJwtError = (authFailure) => {
    console.error('Error fetching JWT:', authFailure);
    };
    pushIntegrationName?: string

    The name of the Iterable push integration that will send push notifications to your app.

    Defaults to your app's application ID or bundle ID for iOS.

    Note: Don't specify this value unless you are using an older Iterable push integration that has a custom name. To view your existing integrations, navigate to Settings > Mobile Apps.

    pushPlatform: IterablePushPlatform = IterablePushPlatform.auto

    This specifies the push platform to use for push notifications. Either sandbox, production, or auto. The default value is auto, which means the SDK will automatically determine the push platform to use. However, you can also set this to sandbox or production to force the SDK to use a specific platform.

    retryPolicy?: IterableRetryPolicy

    Configuration for JWT refresh retry behavior. If not specified, the SDK will use default retry behavior.

    const config = new IterableConfig();
    config.retryPolicy = new IterableRetryPolicy({
    maxRetries: 3,
    initialDelay: 1000,
    maxDelay: 10000,
    });
    unknownUserHandler?: (userId: string) => void

    Called when the native SDK creates a generated user id after unknown-user activation criteria are met.

    JWT-enabled API keys: native logs in as that id immediately after this callback and invokes authHandler without passing the id. Store the userId argument synchronously here so authHandler can mint a token for that id in the same turn. Do not use Iterable.getUserId() in this callback; native has not switched identity yet. In authHandler, consume and clear that pending id on each call so later known-user logins and token refreshes use Iterable.getUserId() instead of a stale cached id.

    Type Declaration

      • (userId: string): void
      • Parameters

        • userId: string

          The generated unknown user id from Iterable.

        Returns void

    let pendingUnknownUserId: string | null = null;
    const config = new IterableConfig();
    config.enableUnknownUserActivation = true;
    config.unknownUserHandler = (userId) => {
    pendingUnknownUserId = userId;
    };
    config.authHandler = async () => {
    const unknownUserId = pendingUnknownUserId;
    pendingUnknownUserId = null;
    const id = unknownUserId ?? (await Iterable.getUserId());
    return fetchJwtForUser(id);
    };
    Iterable.initialize('<YOUR_API_KEY>', config);
    urlHandler?: (url: string, context: IterableActionContext) => boolean

    A callback function used to handle deep link URLs and in-app message button and link URLs.

    Type Declaration

      • (url: string, context: IterableActionContext): boolean
      • Parameters

        • url: string

          The URL to be processed (likely from a click).

        • context: IterableActionContext

          The context in which the URL action is being performed. Describes the source of the URL (push, in-app, or universal link) and information about any associated custom actions.

        Returns boolean

        A boolean indicating whether the URL was successfully handled.

    Use this method to determine whether or not the app can handle the clicked URL. If it can, the method should navigate the user to the right content in the app and return true. Otherwise, it should return false to have the web browser open the URL.

    This example searches for URLs that contain product/, followed by more text. Upon finding this sequence of text, the code displays the appropriate screen and returns true. When it's not found, the app returns false.

    const config = new IterableConfig();

    config.urlHandler = (url, context) => {
    if (url.match(/product/([^/]+)/i)) {
    this.navigate(match[1]);
    return true; // handled
    }
    return false; // not handled
    };

    Iterable.initialize('<YOUR_API_KEY>', config);
    useInMemoryStorageForInApps: boolean = false

    This specifies the useInMemoryStorageForInApps config option downstream to the native SDK layers.

    It determines whether Android and iOS apps should store in-app messages in memory, rather than in an unencrypted local file (defaults to false).

    Please read the respective IterableConfig files for specific details on this config option.

    For more information about this option, and the deprecated-but-related androidSdkUseInMemoryStorageForInApps available in version 1.3.7 of Iterable's React Native SDK, read the release notes for version 1.3.9.

    Methods

    • Converts the IterableConfig instance to a dictionary object.

      Returns {
          allowedProtocols: string[];
          androidSdkUseInMemoryStorageForInApps: boolean;
          androidWakeDelayMs: number;
          authCallbackTimeoutMs: number;
          authHandlerPresent: boolean;
          autoPushRegistration: boolean;
          customActionHandlerPresent: boolean;
          dataRegion: IterableDataRegion;
          decryptionFailureHandlerPresent: boolean;
          enableEmbeddedMessaging: boolean;
          enableForegroundCriteriaFetch: boolean;
          enableUnknownUserActivation: boolean;
          encryptionEnforced: boolean;
          eventThresholdLimit: number;
          expiringAuthTokenRefreshPeriod: number;
          identityResolution: {
              mergeOnUnknownToKnown: boolean;
              replayOnVisitorToKnown: boolean;
          };
          inAppDisplayInterval: number;
          inAppHandlerPresent: boolean;
          keychainEncryption: boolean;
          logLevel: IterableLogLevel;
          onEmbeddedMessageUpdatePresent: boolean;
          onEmbeddedMessagingDisabledPresent: boolean;
          onEmbeddedMessagingSyncFailedPresent: boolean;
          onEmbeddedMessagingSyncSucceededPresent: boolean;
          pushIntegrationName: string
          | undefined;
          pushPlatform: IterablePushPlatform;
          retryPolicy: IterableRetryPolicy | undefined;
          unknownUserHandlerPresent: boolean;
          urlHandlerPresent: boolean;
          useInMemoryStorageForInApps: boolean;
      }

      An object representing the configuration.

      • allowedProtocols: string[]
      • androidSdkUseInMemoryStorageForInApps: boolean
      • androidWakeDelayMs: number
      • authCallbackTimeoutMs: number
      • authHandlerPresent: boolean

        A boolean indicating if an authentication handler is present.

      • autoPushRegistration: boolean
      • customActionHandlerPresent: boolean

        A boolean indicating if a custom action handler is present.

      • dataRegion: IterableDataRegion
      • decryptionFailureHandlerPresent: boolean
      • enableEmbeddedMessaging: boolean
      • enableForegroundCriteriaFetch: boolean
      • enableUnknownUserActivation: boolean
      • encryptionEnforced: boolean
      • eventThresholdLimit: number
      • expiringAuthTokenRefreshPeriod: number
      • identityResolution: { mergeOnUnknownToKnown: boolean; replayOnVisitorToKnown: boolean }
      • inAppDisplayInterval: number
      • inAppHandlerPresent: boolean

        A boolean indicating if an in-app handler is present.

      • keychainEncryption: boolean
      • logLevel: IterableLogLevel

        The log level for the SDK.

      • onEmbeddedMessageUpdatePresent: boolean

        A boolean indicating if an embedded message update callback is present.

      • onEmbeddedMessagingDisabledPresent: boolean

        A boolean indicating if an embedded messaging disabled callback is present.

      • onEmbeddedMessagingSyncFailedPresent: boolean

        A boolean indicating if an embedded messaging sync failed callback is present.

      • onEmbeddedMessagingSyncSucceededPresent: boolean

        A boolean indicating if an embedded messaging sync succeeded callback is present.

      • pushIntegrationName: string | undefined
      • pushPlatform: IterablePushPlatform
      • retryPolicy: IterableRetryPolicy | undefined
      • unknownUserHandlerPresent: boolean

        A boolean indicating if an unknown-user handler is present.

      • urlHandlerPresent: boolean

        A boolean indicating if a URL handler is present.

      • useInMemoryStorageForInApps: boolean