> For the complete documentation index, see [llms.txt](https://cmp.docs.sirdata.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/flutter-setup.md).

# Flutter — Setup

`sirdata_cmp` is a thin Dart layer over the native Sirdata CMP SDKs for Android and iOS. The consent UI, the display decision and the IAB signals all live in the native SDKs: consent is written to native storage, so the ad and analytics SDKs inside your app read it exactly as they would in a native app. The Dart API is for your own logic: deciding when to show the UI, and reading the result.

This page describes version 2.1.0 of the plugin, the first one, which uses the native SDKs 2.1.0. It follows the React Native package 2.1.0 call for call: the same methods, the same rules, the same error codes.

## 1. Prerequisites

|               | Minimum                                          |
| ------------- | ------------------------------------------------ |
| Flutter       | 3.44 (Dart 3.12)                                 |
| iOS           | 15.0: your app's deployment target               |
| Android       | API 23 (the plugin inherits your app's `minSdk`) |
| Android build | What your Flutter version requires; JDK 17       |

* **Flutter 3.44.** The plugin's Android side follows Flutter's "built-in Kotlin" layout: it does not apply the Kotlin Gradle plugin itself, and relies on Flutter 3.44 or later to do it, or on Android Gradle Plugin 9's built-in Kotlin. On an older Flutter, `flutter pub get` refuses the plugin.
* **Your app's activity.** Nothing to change: the consent UI opens from a `FlutterActivity` (the default) as from a `FlutterFragmentActivity`.

## 2. Install

The plugin is not published on pub.dev yet: until it is, this command finds nothing.

```bash
flutter pub add sirdata_cmp
```

or in `pubspec.yaml`:

```yaml
dependencies:
  sirdata_cmp: ^2.1.0
```

Then rebuild the app: a hot reload or a hot restart does not load a plugin's native code.

**Android.** Nothing to add. The SDK, its consent activity and its network permission, as well as the plugin's own components, reach your app through Gradle and manifest merging.

**iOS.** The native SDK comes with the plugin, from Swift Package Manager when your Flutter project uses it (the default in recent Flutter versions), otherwise from CocoaPods (pod `SirdataCMP`). Either way, your app's deployment target must be iOS 15.0 or later:

* with Swift Package Manager: `IPHONEOS_DEPLOYMENT_TARGET = 15.0` or higher for the `Runner` target (in Xcode: *Runner* › *General* › *Minimum Deployments*);
* with CocoaPods: also `platform :ios, '15.0'` at the top of `ios/Podfile`.

## 3. Initialize

Initialize once, as early as possible, and **await it before any other call**:

```dart
import 'package:flutter/widgets.dart';
import 'package:sirdata_cmp/sirdata_cmp.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SirdataCmp.initialize(
    partnerId: 1020, // example ID: use your own partner ID
    configId: 'hmDnl', // example ID: use your own config ID
  );
  runApp(const MyApp());
}
```

`1020` and `'hmDnl'` are the example values used on these pages: replace them with your app's own IDs from the Sirdata Console.

What `initialize()` does:

* it writes `IABTCF_CmpSdkID` (92) to native storage before it completes, then loads the publisher configuration and vendor lists in the background;
* once the configuration has loaded, before any choice, the SDK also writes `IABTCF_gdprApplies`, `IABTCF_PolicyVersion`, `IABTCF_PublisherCC`, `IABTCF_PurposeOneTreatment`, `IABTCF_UseNonStandardTexts`, and for a user under the US regime the GPP keys with the US section. The TC string and the purpose and vendor consents appear only once a choice is recorded;
* called again with the same options, it does nothing: a hot restart runs your `main()` again, and the native SDK keeps its session. Called with other options, it replaces the running session;
* on Android, it keeps its options, so that the SDK starts again on its own when Android restores the consent screen after having stopped the app in the background, before any Dart code runs.

It fails with a `PlatformException` of code `E_INIT` when `partnerId` or `configId` is missing, or when the native SDK refuses to start.

Start the ad and analytics SDKs you control from Dart after it has completed: on a first launch the IAB keys do not exist before it runs.

### Options

| Option                                      | Type                   | Effect                                                                                                                                                                                                             |
| ------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `partnerId`                                 | `int`, required        | Your partner ID                                                                                                                                                                                                    |
| `configId`                                  | `String`, required     | Your config ID                                                                                                                                                                                                     |
| `gdprDefaultApplies`                        | `bool`, default `true` | What `isGdprApplies()` answers before the configuration has loaded, when the device's country cannot be determined. Once the configuration is there, the server decides                                            |
| `apiRoot`, `cacheApiRoot`, `consentApiRoot` | `String`               | Override the three hosts. Leave them unset to use `https://api.consentframework.com/api/v1/public`, `https://choices.consentframework.com/api/v1/public` and `https://mychoice.consentframework.com/api/v1/public` |
| `language`                                  | `String`               | Accepted, but has **no effect**                                                                                                                                                                                    |
| `debugMode`                                 | `bool`                 | Debug builds only: turns a call to the SDK made off the main thread into an error. The plugin makes every call on the main thread, so it has nothing to catch in the plugin itself                                 |

**The UI language and look are not options.** The consent UI uses the language set in your Sirdata configuration if it sets one, otherwise the device language, otherwise the configuration's default language, otherwise English. Its theme (colors, position, buttons) comes from the configuration too, and dark mode selects the configuration's dark colors when it has some.

## 4. Show the consent UI

Let the SDK decide whether to show it, from your first screen, once it is showing:

```dart
class _HomeState extends State<Home> {
  @override
  void initState() {
    super.initState();
    _collectConsent();
  }

  Future<void> _collectConsent() async {
    if (await SirdataCmp.shouldCollectConsent()) {
      await SirdataCmp.showConsentUI();
    }
  }

  // ...
}
```

Do not test the TC string yourself: a partially answered consent must reopen the banner, an active capping window must keep it closed, and neither is visible from the string.

**`shouldCollectConsent()`** runs the same cascade as the web CMP: GDPR applicability, stored consent, cookie wall, the capping windows, and whether the stored choice still covers every active purpose and partner. It **waits for the publisher configuration** first, so you can call it right after `initialize()`. On a network that does not answer, that wait lasts until the HTTP timeouts expire (several tens of seconds), and the answer is then the provisional one: `true` when nothing is stored and GDPR seems to apply from the device. Do not hold a splash screen on it.

What it answers in the common cases:

* **first launch** in a GDPR country: `true`;
* **choice stored and still complete**: `false`. Depending on your configuration's capping setting, the banner can come back once its capping window has elapsed;
* **cookie wall** configured: `true` on every launch until purpose 1 is granted;
* **"Ask me later"** chosen in the banner, with nothing stored: `false` for one hour;
* **GDPR does not apply**, US users included: `false` (section 7).

**`showConsentUI()`** presents the native consent UI (banner, purposes, partners) in the workflow the cascade selects: a choice missing only at partner level opens it in "apply choices" mode, which asks only about what is left. On Android it opens the SDK's consent activity over yours; on iOS it presents the consent view full screen over Flutter's view controller, a presentation the user cannot swipe down.

The future **completes when the UI closes**, whatever closed it: a choice, the close cross, or the Android back button. The back button closes it without recording anything, so the banner comes back at the next decision. Re-read what you need after the future completes. A call made while the UI is already on screen opens nothing more, and completes when it closes.

`showConsentUI()` waits for the end of initialization, and fails, presenting nothing, when the configuration could not be loaded at this launch (no network, for example). It fails with a `PlatformException` of code:

| Code                  | Platform | Cause                                                                     |
| --------------------- | -------- | ------------------------------------------------------------------------- |
| `E_CONFIG_NOT_LOADED` | Both     | The configuration could not be loaded; the message gives the reason       |
| `E_NO_ACTIVITY`       | Android  | Flutter has no activity to present from: the app is not in the foreground |
| `E_NO_VIEWCONTROLLER` | iOS      | No view controller to present from                                        |
| `E_SHOW`              | Both     | Called before `initialize()`, or the presentation failed                  |

`shouldCollectConsent()` fails with `E_SHOULD_COLLECT` if the native decision fails.

## 5. Read the consent

Every getter returns a future, reads the same native storage the vendor SDKs read, and never fails for lack of a choice: before the first choice the TC string, the consent bit strings and the US Privacy string are empty. Under the US regime, the GPP string already carries the US section once the configuration has loaded (section 3).

```dart
Future<bool> canUseAnalytics() async {
  final device = await SirdataCmp.hasPurposeConsent(1); // purpose 1: store or access information on a device
  final google = await SirdataCmp.hasVendorConsent(755); // 755 = Google in the Global Vendor List
  final analytics = await SirdataCmp.hasSirdataVendorConsent(8); // 8 = Google Analytics in the Sirdata list
  return device && google && analytics;
}
```

| Getter                                           | Returns                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getTcString()`                                  | `IABTCF_TCString`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `getPurposeConsents()` / `getVendorConsents()`   | `IABTCF_PurposeConsents` / `IABTCF_VendorConsents`, bit strings where character *n* is purpose or vendor *n*                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `hasPurposeConsent(id)` / `hasVendorConsent(id)` | Whether bit `id` (1-based) is set in those strings                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `getGppString()`                                 | `IABGPP_HDR_GppString`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `getUspString()`                                 | `IABUSPrivacy_String`: empty until a US user saves the US screen                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `getAddtlConsent()`                              | `IABTCF_AddtlConsent`, Google's Additional Consent string                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `isGdprApplies()`                                | The server's answer once the configuration has loaded; before, a guess from the device's country                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `isCcpaApplies()`                                | The same, for the US regime                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `getSirdataConsents()`                           | What the user last recorded for the partners of the Sirdata list (the "Extra Vendors" of the Sirdata Console, such as Google Analytics, 8, or Microsoft Clarity, 45) and for its purposes, in the shape of the web CMP's `tcData.sirdata`: a `SirdataConsents` with `sdString`, `vendor` and `purpose`, each with `consents` and `legitimateInterests` maps keyed by ID. A partner has consent only if the user accepted it and it asks for consent. `null` where GDPR does not apply, before a choice is recorded, before `initialize()`, or while the Sirdata list is not loaded |
| `hasSirdataVendorConsent(id)`                    | Whether the partner `id` of the Sirdata list has the user's recorded consent; `false` whenever `getSirdataConsents()` gives `null`                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

`hasVendorConsent()` reads only the IAB vendors: the partners of the Sirdata list are not in the TC string. Unlike the other getters, the two Sirdata ones read the choice the SDK recorded rather than the IAB storage, so they need `initialize()` to have completed.

### React to changes

```dart
StreamSubscription<ConsentSnapshot> watchConsent(void Function(ConsentSnapshot) onChange) {
  String? lastSeen;
  return SirdataCmp.consentChanges.listen((snapshot) {
    // Compare values: on Android the stream also emits when nothing stored changed.
    // sdString changes alone when the user refuses only a partner of the Sirdata list.
    final key = [snapshot.tcString, snapshot.gppString, snapshot.uspString, snapshot.sdString].join('|');
    if (key == lastSeen) return;
    lastSeen = key;
    onChange(snapshot);
  });
}

// When you no longer need it: subscription.cancel();
```

`consentChanges` emits a `ConsentSnapshot` of the stored values (`tcString`, `purposeConsents`, `vendorConsents`, `gppString`, `uspString`, `addtlConsent`, `gdprApplies`, `sdString`, the recorded Sirdata string), but the two platforms do not emit at the same moments. **Compare values rather than count events**:

|          | Android                                                                                                                                                                           | iOS                                                                                                                                                                                                                            |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Emits on | Every update of the SDK's consent state: while the configuration loads, on each toggle inside the consent UI before the user saves, on each save, and when the US screen is saved | Only when `IABTCF_TCString`, `IABUSPrivacy_String`, `IABGPP_HDR_GppString` or the recorded Sirdata string actually changes in `UserDefaults`, which for a user under the US regime includes the configuration load (section 3) |

Both platforms start emitting once `initialize()` has completed. Re-read the values you depend on when `showConsentUI()` completes, rather than relying on the stream alone.

`consentUIClosed` emits each time a consent UI opened by `showConsentUI()` closes, at the moment its future completes. Both are broadcast streams: listen as many times as you need, and cancel each subscription when you are done.

## 6. Reopen from a settings screen

GDPR requires choices to be editable at any time. Give the user an entry point that calls `showConsentUI()` again:

```dart
// e.g. the onPressed of a "Manage cookies" button in your settings screen
Future<void> onManageConsentPressed() async {
  await SirdataCmp.showConsentUI();
  // re-read and re-apply what you gate on consent here
}
```

`showConsentUI()` decides how to open as the web CMP does. When the consent UI is due, which is what `shouldCollectConsent()` answers `true` for, it opens in the workflow the display decision selects: that is what your first screen needs. Otherwise (a complete choice is stored, a capping window is active, or GDPR does not apply) the opening comes from your app, so it opens in the native SDKs' reopen mode (`MANUAL_DISPLAY`), as the web's `displayUI()` does: a close cross at the top and a "Reject all" button whatever the refusal option your configuration sets, so the user can withdraw in one tap. The reopening restarts the capping window and counts as a revisit in Sirdata's statistics. Pass `reopen: true` to open the reopen mode even when the UI is due, for example while a choice is only partly answered:

```dart
await SirdataCmp.showConsentUI(reopen: true);
```

The close cross of the reopen mode changes no choice. Where the server applies the CNIL rules, France included, it records the choices on screen as it closes, as on the web: the TC string is then rewritten and `consentChanges` can emit (section 5).

## 7. US users

GDPR does not apply to US users, so `shouldCollectConsent()` answers `false` and no banner appears on its own. When the US regime applies, `showConsentUI()` presents the **US screen** instead of the TCF banner: the user can opt out, and saving it writes `IABUSPrivacy_String` and the US sections of the GPP string.

Offer US users an entry point in your settings, for example labeled "Your Privacy Choices", that calls `showConsentUI()`, and show it when `await SirdataCmp.isCcpaApplies()` is `true`. The server decides the regime from the country and US state it locates the connection in, once the configuration has loaded; before that, `isCcpaApplies()` is a guess from the device's country. There is no `setCcpaOptOut` in Dart: the opt-out goes through the US screen. Saving it makes `consentChanges` emit on both platforms, with `uspString` and `gppString`.

## 8. Vendor SDKs

Most vendor SDKs in a Flutter app are native SDKs wrapped by a plugin (`firebase_analytics`, `google_mobile_ads`, `appsflyer_sdk`, …), and they read consent from native storage as they would in a native app. There is nothing to pass from Dart, and the rules on [Sharing consent with vendor SDKs](https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/sharing-consent.md) apply unchanged:

* IAB-compliant SDKs (Google Mobile Ads and others) need nothing;
* the consent adapters (Firebase Analytics, AppsFlyer, Adjust, Branch) look for the vendor's native classes at run time, as in a native app, so they apply to a vendor SDK that a Flutter plugin links into your app;
* AppsFlyer still has to be told to read the IAB keys: use the option its Flutter plugin exposes for that (see the plugin's documentation);
* SDKs that do not read the IAB keys, such as Meta's, are yours to gate: start them from Dart on `hasPurposeConsent(...)` / `hasVendorConsent(...)`, and re-evaluate on changes (section 5).

Collect consent before you load the first ad.

## 9. Test and verify

Use your own configuration for testing. If you start with the example IDs of these pages, switch to your own before release, and clear the app's data when you do (see the last point below).

To replay a first launch, uninstall the app, or on Android clear its data (replace `com.example.myapp` with your `applicationId`):

```bash
adb shell pm clear com.example.myapp
```

Check, on each platform:

1. **The native dependencies.** Android, from your project's `android/` directory:

   ```bash
   ./gradlew :app:dependencies --configuration releaseRuntimeClasspath | grep com.sirdata.cmp
   ```

   lists `android-sdk`, `shared` and `shared-android` at 2.1.0. iOS: with Swift Package Manager, Xcode lists `sirdata-cmp-ios-spm` 2.1.0 (or a later 2.x) under *Package Dependencies*; with CocoaPods, `pod install` installs `sirdata_cmp (2.1.0)` and `SirdataCMP` (2.1.0, or a later 2.x).
2. **First launch** (from a GDPR country): `shouldCollectConsent()` gives `true` and the banner appears.
3. **After "Accept all"**: `getTcString()` is not empty and `hasPurposeConsent(1)` is `true`. For a user outside the US, `getUspString()` stays empty.
4. **Relaunch**: no banner.
5. **Settings entry**: once a choice is recorded, `showConsentUI()` opens the UI with a close cross at the top and a "Reject all" button, and completes when it closes. After "Accept all", "Reject all" there leaves `hasPurposeConsent(1)` `false`.
6. **US screen**: from a connection the server places in a covered US state (California, for example), `isCcpaApplies()` is `true`, `showConsentUI()` shows the US screen, and after saving it `getUspString()` is no longer empty.
7. **Release build**: the banner still appears in a minified Android release build (`flutter build apk --release`) and in an iOS Release build.

To look at the raw keys on Android, in a debuggable build:

```bash
adb shell run-as com.example.myapp cat shared_prefs/com.example.myapp_preferences.xml
```

`IABTCF_CmpSdkID` is `92` as soon as `initialize()` has completed.

On Android, Logcat shows the SDK's own lines under the tags `SirDataCMP` and `SirDataCMPManager`, including `Config load failed: …` when the configuration cannot be loaded. On iOS, the Xcode console shows lines starting with `[CMP]`. See [Logging](https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/logging.md).

**Switching partner or config ID**: stored consent belongs to the configuration that collected it, so clear the app's data or reinstall when you switch. There is no `clearConsent()` in Dart.

The plugin's example app (`example/` in the package) runs these checks on a test screen, and its integration test runs the Dart API against the real native SDKs on a simulator or a device: `flutter test integration_test`, from `example/`.

## 10. Release builds

* **Android minification.** Nothing to add: the SDK's R8 rules ship inside it (consumer rules) and apply to your minified release build, the consent adapters included.
* **`debugMode`.** Leave it unset in release builds (section 3).
* **Apple privacy manifest.** Neither the native SDK (2.1.0) nor this plugin (2.1.0) ships a privacy manifest (`PrivacyInfo.xcprivacy`). The SDK stores consent in `UserDefaults`, which Apple lists as a required-reason API (category `NSPrivacyAccessedAPICategoryUserDefaults`). Apple explains who declares what in [Describing use of required reason API](https://developer.apple.com/documentation/bundleresources/describing-use-of-required-reason-api): review it for your app before you submit.
* **Attribution notices.** The plugin carries `LICENSE`, `NOTICE-android`, `NOTICE-ios` and `THIRD-PARTY-LICENSES/`. The Android and iOS builds embed different third-party components, hence two notices: both use components under the Apache License 2.0, the Android build also uses slf4j under the MIT licence, and the iOS build a component under the Boost Software License 1.0. If you distribute your app, make available to your users, for example in your open-source licences screen, the notice of each platform you ship (`NOTICE-android`, `NOTICE-ios`) and the licence texts in `THIRD-PARTY-LICENSES/`: it is required by section 26.1(b) of the `LICENSE`, and by the Apache License 2.0 (section 4) for the components it covers.
* **Licence.** Shipping your app requires a valid, current subscription to the Sirdata Consent Management Platform; one taken through the Sirdata Console is enough, and no signed agreement is required (section 25.1 of the `LICENSE`). Without a subscription, the licence is a 90-day evaluation grant: internal evaluation, development, testing and integration only, with no distribution to third parties or app stores (section 1.4). Subscriptions: [sirdata.com](https://sirdata.com); licence questions: <legal@sirdata.com>.

## 11. API reference

```dart
import 'package:sirdata_cmp/sirdata_cmp.dart';
```

Every method of `SirdataCmp` is static and returns a future. A failed future carries a `PlatformException` whose `code` is one of the codes below.

### Lifecycle

```dart
static Future<void> initialize({
  required int partnerId,
  required String configId,
  String? language, // no effect in 2.1.0
  String? apiRoot,
  String? cacheApiRoot,
  String? consentApiRoot,
  bool? debugMode, // debug builds only
  bool? gdprDefaultApplies,
});
static Future<bool> isInitialized();
```

`initialize()` starts the native SDK (section 3) and fails with `E_INIT`. `isInitialized()` is `true` once the native `initialize` has run. It does not mean the configuration has loaded: `shouldCollectConsent()` waits for that.

### Display

```dart
static Future<bool> shouldCollectConsent();
static Future<void> showConsentUI({bool reopen = false});
```

`shouldCollectConsent()` waits for the publisher configuration, then answers whether the consent UI must be shown now (section 4); it fails with `E_SHOULD_COLLECT`. `showConsentUI()` presents the consent UI and completes when it closes: when the UI is due, in the workflow the cascade selects (section 4); otherwise, and always with `reopen: true`, in the reopen mode for a settings screen (section 6). It fails with `E_CONFIG_NOT_LOADED`, `E_NO_ACTIVITY` (Android), `E_NO_VIEWCONTROLLER` (iOS) or `E_SHOW`.

### Programmatic choices

```dart
static Future<void> acceptAll();
static Future<void> rejectAll();
```

Accept or reject every purpose, vendor and feature, and record the choice, for a consent screen of your own. A choice is made on the vendor lists the configuration brings: they wait for the end of initialization, then record the choice on the real lists. They fail with `E_ACCEPT_ALL` / `E_REJECT_ALL`, recording nothing, when the configuration could not be loaded ("Configuration not loaded, nothing recorded"), before `initialize()`, and whenever the native SDK reports the submission as failed.

### Getters

```dart
static Future<String> getTcString();
static Future<String> getPurposeConsents();
static Future<String> getVendorConsents();
static Future<String> getGppString();
static Future<String> getUspString();
static Future<String> getAddtlConsent();
static Future<bool> hasPurposeConsent(int purposeId);
static Future<bool> hasVendorConsent(int vendorId);
static Future<bool> isGdprApplies();
static Future<bool> isCcpaApplies();
static Future<SirdataConsents?> getSirdataConsents();
static Future<bool> hasSirdataVendorConsent(int vendorId);
```

See the table in section 5. `SirdataConsents` has `sdString`, `vendor` and `purpose`; `vendor` and `purpose` are `SirdataBasis` objects with two unmodifiable `Map<int, bool>`, `consents` and `legitimateInterests`, and `SirdataConsents` offers `hasVendorConsent`, `hasVendorLegitimateInterest`, `hasPurposeConsent` and `hasPurposeLegitimateInterest`. On Android a getter fails with `E_CMP` if the native call throws, and both platforms fail with `E_CMP` when an ID getter receives no ID.

### Events

```dart
static Stream<ConsentSnapshot> get consentChanges;
static Stream<void> get consentUIClosed;
```

Broadcast streams, shared by every listener. See section 5 for when each emits on each platform. `ConsentSnapshot` has `tcString`, `purposeConsents`, `vendorConsents`, `gppString`, `uspString`, `addtlConsent`, `gdprApplies` and `sdString`.

### Not available from Dart in 2.1.0

| Native feature                                                                                                                              | Instead                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| The display decision's workflow and reason (`awaitConsentDisplayDecision`)                                                                  | `shouldCollectConsent()` gives the yes or no; `showConsentUI()` picks the workflow itself                                          |
| `saveConsent()`, `submitConsent()`, `recordAskLater()`                                                                                      | The consent UI's own buttons, or `acceptAll()` / `rejectAll()`                                                                     |
| `setCcpaOptOut()`, `isCcpaOptedOut()`                                                                                                       | The US screen through `showConsentUI()`, then `getUspString()` (section 7)                                                         |
| `clearConsent()`, `shutdown()`                                                                                                              | Clear the app's data or reinstall (section 9)                                                                                      |
| The TCF, GPP and USP command APIs (`tcfApi()`, `gppApi()`, `uspApi()`)                                                                      | Vendor SDKs read native storage; use the getters for your own logic                                                                |
| Google Consent Mode state and the consent adapters (`getGoogleConsentState()`, `getLastForwardedConsentState()`, `getRegisteredAdapters()`) | The adapters run natively without any call (section 8)                                                                             |
| Initialization state and errors (`getConsentState()`, `getInitError()`, `getLastTcStringError()`)                                           | `showConsentUI()` gives the reason in its `E_CONFIG_NOT_LOADED` message. Android: Logcat, tag `SirDataCMPManager`                  |
| Android `certificatePins`                                                                                                                   | Not configurable from Dart                                                                                                         |
| The free plan collection calls (`setUserEmail()`, `trackScreen()`, `setAutomaticScreenCapture()`, `isAudienceCollectionEligible()`)         | None: on a configuration of the free plan, the native SDKs 2.1.0 collect what they read by themselves (see their *Versions* pages) |

## 12. Troubleshooting

| Symptom                                                                                                                      | Cause and fix                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `flutter pub get`: "Because sirdata\_cmp requires Flutter SDK version >=3.44.0, version solving failed"                      | Your Flutter is older than 3.44. Upgrade Flutter (section 1)                                                                                                                                               |
| `MissingPluginException(No implementation found for method initialize on channel com.sirdata.cmp/methods)`                   | The app was not rebuilt after adding the plugin: a hot reload or a hot restart does not load native code. Stop the app and run it again                                                                    |
| Xcode, Swift Package Manager: "the package product 'SirDataCMP' requires minimum platform version 15.0 for the iOS platform" | Your `Runner` target's deployment target is below iOS 15.0. Raise it (section 2)                                                                                                                           |
| `pod install`: "required a higher minimum deployment target"                                                                 | Your `Podfile`'s `platform :ios` is below 15.0. Raise it to at least `'15.0'`                                                                                                                              |
| `pod install`: "Unable to find a specification" or "could not find compatible versions" for `SirdataCMP`                     | Your local CocoaPods specs are out of date: run `pod install --repo-update` from `ios/`                                                                                                                    |
| `showConsentUI()` fails with `E_CONFIG_NOT_LOADED`                                                                           | The configuration could not be loaded at this launch: no network, or an unknown partner or config ID. The message gives the reason. The SDK does not retry during the launch: try again at the next launch |
| `acceptAll()` / `rejectAll()` fail with "Configuration not loaded, nothing recorded"                                         | The same cause: nothing was recorded                                                                                                                                                                       |
| `showConsentUI()` fails with `E_NO_ACTIVITY`                                                                                 | Flutter had no activity: the app was not in the foreground. Call it from a screen that is showing                                                                                                          |
| No banner for a US user                                                                                                      | Expected: GDPR does not apply. Offer the US screen from your settings (section 7)                                                                                                                          |
| The settings entry shows the first-visit banner                                                                              | The UI is due at that moment, a choice being missing or partly answered: pass `reopen: true` to open the reopen mode anyway (section 6)                                                                    |

For anything else, see [Troubleshooting](https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/troubleshooting.md), and include the SDK version, the platform, your partner ID and config ID when you contact Sirdata.

## Next

* [Sharing consent with vendor SDKs](https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/sharing-consent.md) — how ad SDKs read the consent you collect


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk/flutter-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
