diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fa81c938..c38a090b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Updates +- Added `IterableConfig.enableForegroundCriteriaFetch` (default `true`) to control whether the SDK fetches unknown-user targeting criteria when the app enters the foreground (SDK-554). - Added `IterableConfig.eventThresholdLimit` (default `100`) to cap locally stored unknown-user events before identification (SDK-553). The value is forwarded to the native SDK; it has no runtime effect in React Native until `enableUnknownUserActivation` is exposed in a future release (that switch is not on the RN config surface yet). ## 3.2.1 diff --git a/android/src/main/java/com/iterable/reactnative/Serialization.java b/android/src/main/java/com/iterable/reactnative/Serialization.java index 51c5d3368..a1a1d0d50 100644 --- a/android/src/main/java/com/iterable/reactnative/Serialization.java +++ b/android/src/main/java/com/iterable/reactnative/Serialization.java @@ -251,6 +251,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")); } diff --git a/ios/RNIterableAPI/Serialization.swift b/ios/RNIterableAPI/Serialization.swift index b0b1bda2c..b7e5194e3 100644 --- a/ios/RNIterableAPI/Serialization.swift +++ b/ios/RNIterableAPI/Serialization.swift @@ -87,6 +87,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 } diff --git a/src/core/classes/Iterable.test.ts b/src/core/classes/Iterable.test.ts index 53e8dd69a..9bd4ef811 100644 --- a/src/core/classes/Iterable.test.ts +++ b/src/core/classes/Iterable.test.ts @@ -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); @@ -345,6 +346,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); @@ -368,6 +370,13 @@ describe('Iterable', () => { 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); + }); + it('should include eventThresholdLimit in toDict() when overridden', () => { const config = new IterableConfig(); config.eventThresholdLimit = 50; diff --git a/src/core/classes/IterableConfig.ts b/src/core/classes/IterableConfig.ts index e30639bbd..a284e87af 100644 --- a/src/core/classes/IterableConfig.ts +++ b/src/core/classes/IterableConfig.ts @@ -403,6 +403,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? * @@ -497,6 +505,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,