Skip to content

MOBILE-621: Hold the IDFA set before init until the flag is known - #246

Open
justSmK wants to merge 2 commits into
developfrom
feature/MOBILE-621-idfa-before-init
Open

justSmK wants to merge 2 commits into
developfrom
feature/MOBILE-621-idfa-before-init

Conversation

@justSmK

@justSmK justSmK commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

https://tracker.yandex.ru/MOBILE-621

The Flutter twin of mindbox-cloud/react-native-sdk#251. disableTrackingIds lives only in the Dart isolate. A new isolate in a live process (restart_app's iOS engine restart, an add-to-app host that re-creates its FlutterEngine, a plugin's background engine) starts with the flag off while the native SDK stays initialized, so setAdvertisingIdentifier(idfa) called before that isolate's init sent the IDFA to the tracking host although the app had turned tracking ids off.

Until init runs in the isolate, the setter keeps the last value in Dart. init passes null (flag on) or that value (flag off) to native before the native initialization, so a cold start reaches native in the same order as before. No native change.

The rule moved into AdvertisingIdentifierGate, because the Mindbox facade is a per-isolate singleton that tests in one file share; the tests start from a fresh gate.

Checked: flutter analyze and flutter test in mindbox with local path dependencies. The first and third new tests fail on develop's behaviour; the second and third were seen red on a one-line break of the line each guards.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change that defers pre-initialization identifier forwarding until the isolate’s tracking preference is known.

No open issues 🎉

What changed in this PR

Prevents an IDFA set before initialization from reaching the iOS SDK before the current Dart isolate’s disableTrackingIds setting is known. This protects restarted or newly created isolates when the native SDK remains initialized, without native changes.

Changes:

  • Adds a gate that holds the latest pre-init identifier and forwards it—or null when tracking IDs are disabled—before native initialization.
  • Routes the Mindbox facade through the gate and documents the deferred behavior.
  • Adds tests for disabled tracking, enabled tracking, and consent withdrawal before initialization.
File Description
mindbox/​test/​advertising_identifier_gate_test.dart Tests pre-init buffering and identifier forwarding for three consent scenarios.
mindbox/​lib/​src/​advertising_identifier_gate.dart Adds per-isolate buffering and tracking-flag enforcement.
mindbox/​lib/​mindbox.dart Integrates the gate and documents pre-init identifier handling.

Review effort: Balanced

disableTrackingIds lives only in the Dart isolate. A new isolate in a live process (restart_app's iOS engine restart, an add-to-app host that re-creates its FlutterEngine, a plugin's background engine) starts with the flag off while the native SDK stays initialized, so an IDFA set before that isolate's init reached the tracking host although the app had turned tracking ids off. Same flaw as the React Native JS reload found on the acceptance stand.

The rule moves into its own type so that a test can start from a fresh instance; the Mindbox facade is a per-isolate singleton.
@justSmK
justSmK force-pushed the feature/MOBILE-621-idfa-before-init branch from a9768d1 to 0784eb5 Compare November 20, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants