Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Updates

- Added `IterableConfig.enableForegroundCriteriaFetch` (default `true`) to control whether the SDK fetches unknown-user targeting criteria when the app enters the foreground (SDK-554).

## 3.2.1

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ static IterableConfig.Builder getConfigFromReadableMap(ReadableMap iterableConte
configBuilder.setDataRegion(iterableDataRegion);
}

if (iterableContextJSON.has("enableForegroundCriteriaFetch")) {
configBuilder.setEnableForegroundCriteriaFetch(iterableContextJSON.optBoolean("enableForegroundCriteriaFetch"));
}

if (iterableContextJSON.has("enableEmbeddedMessaging")) {
configBuilder.setEnableEmbeddedMessaging(iterableContextJSON.optBoolean("enableEmbeddedMessaging"));
}
Expand Down
4 changes: 4 additions & 0 deletions ios/RNIterableAPI/Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ extension IterableConfig {
config.useInMemoryStorageForInApps = useInMemoryStorageForInApp
}

if let enableForegroundCriteriaFetch = dict["enableForegroundCriteriaFetch"] as? Bool {
config.enableForegroundCriteriaFetch = enableForegroundCriteriaFetch
}

if let enableEmbeddedMessaging = dict["enableEmbeddedMessaging"] as? Bool {
config.enableEmbeddedMessaging = enableEmbeddedMessaging
}
Expand Down
9 changes: 9 additions & 0 deletions src/core/classes/Iterable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ describe('Iterable', () => {
expect(config.checkForDeferredDeeplink).toBe(false);
expect(config.customActionHandler).toBe(undefined);
expect(config.dataRegion).toBe(IterableDataRegion.US);
expect(config.enableForegroundCriteriaFetch).toBe(true);
expect(config.enableEmbeddedMessaging).toBe(false);
expect(config.encryptionEnforced).toBe(false);
expect(config.expiringAuthTokenRefreshPeriod).toBe(60.0);
Expand All @@ -344,6 +345,7 @@ describe('Iterable', () => {
expect(configDict.autoPushRegistration).toBe(true);
expect(configDict.customActionHandlerPresent).toBe(false);
expect(configDict.dataRegion).toBe(IterableDataRegion.US);
expect(configDict.enableForegroundCriteriaFetch).toBe(true);
expect(configDict.enableEmbeddedMessaging).toBe(false);
expect(configDict.encryptionEnforced).toBe(false);
expect(configDict.expiringAuthTokenRefreshPeriod).toBe(60.0);
Expand All @@ -365,6 +367,13 @@ describe('Iterable', () => {
expect(configDict.androidWakeDelayMs).toBe(1500);
expect(configDict.authCallbackTimeoutMs).toBe(2500);
});

it('should include enableForegroundCriteriaFetch in toDict() when set to false', () => {
const config = new IterableConfig();
config.enableForegroundCriteriaFetch = false;
const configDict = config.toDict();
expect(configDict.enableForegroundCriteriaFetch).toBe(false);
});
});

describe('urlHandler', () => {
Expand Down
9 changes: 9 additions & 0 deletions src/core/classes/IterableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@ export class IterableConfig {
*/
authCallbackTimeoutMs = 6000;

/**
* 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.
*/
enableForegroundCriteriaFetch = true;

/**
* Should the SDK enable and use embedded messaging?
*
Expand Down Expand Up @@ -484,6 +492,7 @@ export class IterableConfig {
pushPlatform: this.pushPlatform,
encryptionEnforced: this.encryptionEnforced,
retryPolicy: this.retryPolicy,
enableForegroundCriteriaFetch: this.enableForegroundCriteriaFetch,
enableEmbeddedMessaging: this.enableEmbeddedMessaging,
androidWakeDelayMs: this.androidWakeDelayMs,
authCallbackTimeoutMs: this.authCallbackTimeoutMs,
Expand Down
Loading