From f4e88c8162444d2013b882b91d509a383ad32baf Mon Sep 17 00:00:00 2001 From: Sergei Semko <28645140+justSmK@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:50:36 +0300 Subject: [PATCH 1/2] MOBILE-621: Hold the IDFA set before initialize until the flag is known disableTrackingIds lives only in JS. A JS reload without a process restart (expo-updates reloadAsync, react-native-restart) resets it while the native SDK stays initialized, so an IDFA set before the next initialize reached the tracking host although the app had turned tracking ids off. Found on the acceptance stand with a deferred initialize. --- src/index.tsx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 0e3f789..5275fc7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -11,7 +11,8 @@ class MindboxSdkClass { private _initialized: boolean private _initializing: boolean private _callbacks: Array<() => void> - private _disableTrackingIds: boolean + private _disableTrackingIds?: boolean + private _pendingAdvertisingIdentifier?: string | null private _mindboxJsDeliveryEvents: NativeEventEmitter private _emitterSubscribtion?: EmitterSubscription private readonly _prefix: string = '[RN]' @@ -20,7 +21,6 @@ class MindboxSdkClass { this._initialized = false this._initializing = false this._callbacks = [] - this._disableTrackingIds = false this._mindboxJsDeliveryEvents = new NativeEventEmitter(MindboxJsDelivery) } @@ -143,10 +143,16 @@ class MindboxSdkClass { } this._disableTrackingIds = disableTrackingIds === true + const pendingAdvertisingIdentifier = this._pendingAdvertisingIdentifier + this._pendingAdvertisingIdentifier = undefined try { - if (this._disableTrackingIds && Platform.OS === 'ios') { - MindboxSdkNative.setAdvertisingIdentifier?.(null) + if (Platform.OS === 'ios') { + if (this._disableTrackingIds) { + MindboxSdkNative.setAdvertisingIdentifier?.(null) + } else if (pendingAdvertisingIdentifier !== undefined) { + MindboxSdkNative.setAdvertisingIdentifier?.(pendingAdvertisingIdentifier) + } } const payloadString = JSON.stringify(payload) @@ -486,7 +492,8 @@ class MindboxSdkClass { * The SDK does not read the IDFA itself: call this method at launch and on every return to the * foreground. `null`, an empty string or zeros mean there is no tracking consent and clear the * IDFA sent earlier. The IDFA is sent only if the app's `PrivacyInfo.xcprivacy` declares the - * Mindbox tracking host. + * Mindbox tracking host. A value set before `initialize` is held and passed on by `initialize` + * once `disableTrackingIds` is known. * * @param identifier the IDFA, or `null` when tracking is not authorized * @@ -498,6 +505,11 @@ class MindboxSdkClass { return } + if (this._disableTrackingIds === undefined) { + this._pendingAdvertisingIdentifier = identifier + return + } + MindboxSdkNative.setAdvertisingIdentifier(this._disableTrackingIds ? null : identifier) } From aafd0b7c99faf4c19a42003171d99572e4cadbef Mon Sep 17 00:00:00 2001 From: Sergei Semko <28645140+justSmK@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:50:39 +0300 Subject: [PATCH 2/2] MOBILE-621: Pin the IDFA hold before initialize --- src/__tests__/index.test.ts | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 703bdbd..865e2fa 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -627,6 +627,47 @@ describe('Testing Mindbox RN SDK', () => { expect(setIdentifier.mock.calls).toEqual([[null]]) }) + it('holds an identifier set before initialize until disableTrackingIds is known', async () => { + const { MindboxSdk, setIdentifier } = load('ios') + + MindboxSdk.setAdvertisingIdentifier(idfa) + expect(setIdentifier).not.toHaveBeenCalled() + + await MindboxSdk.initialize({ ...initializationData, disableTrackingIds: true }) + + expect(setIdentifier.mock.calls).toEqual([[null]]) + }) + + it('passes an identifier held before initialize to native before the native initialization', async () => { + const { MindboxSdk, setIdentifier, initialize } = load('ios') + + MindboxSdk.setAdvertisingIdentifier(idfa) + await MindboxSdk.initialize(initializationData) + + expect(setIdentifier.mock.calls).toEqual([[idfa]]) + expect(setIdentifier.mock.invocationCallOrder[0]).toBeLessThan(initialize.mock.invocationCallOrder[0]) + }) + + it('passes only the last value set before initialize, so a withdrawn consent reaches native as null', async () => { + const { MindboxSdk, setIdentifier } = load('ios') + + MindboxSdk.setAdvertisingIdentifier(idfa) + MindboxSdk.setAdvertisingIdentifier(null) + await MindboxSdk.initialize(initializationData) + + expect(setIdentifier.mock.calls).toEqual([[null]]) + }) + + it('passes an identifier set while initialize is in flight', async () => { + const { MindboxSdk, setIdentifier } = load('ios') + + const initializing = MindboxSdk.initialize(initializationData) + MindboxSdk.setAdvertisingIdentifier(idfa) + await initializing + + expect(setIdentifier.mock.calls).toEqual([[idfa]]) + }) + it('initialize with disableTrackingIds clears the identifier in native before the native initialization', async () => { const { MindboxSdk, setIdentifier, initialize } = load('ios')