The following documentation outlines the APIs available for use in the TrustArc Mobile Consent SDK for Flutter.
FlutterTrustarcMobileConsentSdk Class
The FlutterTrustarcMobileConsentSdk class is the main entry point for interacting with the TrustArc SDK.
Constructor
| Constructor | Description |
| FlutterTrustarcMobileConsentSdk() | Provides methods for interacting with the TrustArc SDK |
Initialization Methods
| Methods | Description | Parameters | Return |
| initialize | Initializes the TrustArc SDK. | sdkMode: SdkMode | Future |
| start | Starts the TrustArc SDK. Supports backward-compatible calling forms. | domainName: String, country: String, [state] or [language, state] | Future |
| isSdkInitialized | Validates if SDK setup is finished. | None | Future |
| subscribe | Subscribes to SDK events. | onSdkInitFinish, onConsentChanges, onGoogleConsentChanges | void |
Consent Management Methods
| Methods | Description | Parameters | Return |
| openCM | Manually opens the consent window. | None | Future |
| useGdprDetection | Overrides behavior to Expressed mode for startup checks. | enable: bool | Future |
| setUnifiedConsentContext | Sets Unified Consent context key (domain resolved from start(...)). | key: String (required named param) | Future |
| setUnifiedConsentIdentity | Sets Unified Consent identity with user id + HMAC. | userId: String, hmac: String | Future |
| enableAppTrackingTransparencyPrompt | Enables/disables ATT prompt on iOS (no-op on Android). | enabled: bool | Future |
| setBackgroundWebViewVisible | Shows/hides background WebView for debugging. | visible: bool | Future |
| clearAllConsentData | Clears stored consent data/preferences. | None | Future |
Information Retrieval Methods
| Methods | Description | Parameters | Return |
| getStoredConsentData | Retrieves stored consent data. | None | Future |
| getConsentDataByCategory | Retrieves consent data grouped by category. | None | Future |
| getCategoryConsent | Retrieves consent value for a specific category index. | categoryIndex: int | Future<String?> |
| isCategoryConsented | Checks if a specific category is consented. | categoryIndex: int | Future |
| getWebScript | Retrieves web script for web integration. | None | Future |
| isConsentPresent | Checks if consent is present. | None | Future |
| getConsentValue | Retrieves consent value for a specific tracker. | trackerId: String | Future |
| getTrustArcDeviceUUID | Retrieves consent identifier for the device. | None | Future |
| getLastConsent | Retrieves timestamp of last consent update. | None | Future |
| getConsentLanguage | Retrieves language used by the SDK. | None | Future |
| getGoogleConsents | Retrieves Google consent payload. | None | Future |
| getBehavior | Retrieves consent behavior setting. | None | Future |
| getSharedPreferences | Retrieves native shared preference values. | None | Future<Map<String, dynamic>> |
| getIABTCFPreferences | Retrieves IAB TCF preferences. | None | Future |
| getTcfString | Retrieves TC string (deprecated; use getSharedPreferences().IABTCF_TCString). | None | Future |
| getTrackingAuthorizationStatus | Gets ATT authorization status (iOS); Android returns notApplicable. | None | Future |
| isConsentExpired | Checks if stored consent has expired. | None | Future |
| getConsentExpiryDate | Retrieves stored expiry timestamp (deprecated). | None | Future<int?> |
| getStoredConsentExpiry | Retrieves stored expiry timestamp in milliseconds. | None | Future<int?> |
Debug and Testing Methods
| Methods | Description | Parameters | Return |
| generateHmacAuthId | Testing-only helper to generate HMAC auth id for Unified Consent workflows. | userId: String, key: String | Future<String?> |
| enableDebugLog | Enables/disables debug logging. | enabled: bool | Future |
SdkMode Enum
Defines the mode in which the SDK operates.
| Property | Type | Description |
| standard | String | Standard consent collection mode |
| iabTCFv_2_2 | String | IAB TCF compliant layout mode |
IABTCFPreferences
Represents IAB Transparency & Consent Framework preferences.
| Field | Description |
| IABTCF_PurposeOneTreatment | Indicates if Purpose One has special treatment (0 = no, 1 = yes) |
| IABTCF_VendorConsents | Encoded string representing vendor consents |
| IABTCF_enableAdvertiserConsentMode | Whether advertiser consent mode is enabled
Google’s latest Firebase SDK release for iOS and Android now supports TCF. To ensure proper consent handling and compatibility with the SDK, please set IABTCF_enableAdvertiserConsentMode to 1 when using TCF so Google can infer consent from the TC string. |
| IABTCF_PublisherCC | Publisher’s country code (e.g., "DE", "FR") |
| IABTCF_PublisherConsent | Encoded string representing publisher-specific consent |
| IABTCF_gdprApplies | Indicates if GDPR applies (0 = no, 1 = yes) |
| IABTCF_SpecialFeaturesOptIns | Encoded string representing special feature opt-ins |
| IABTCF_VendorLegitimateInterests | Encoded string representing vendor legitimate interests |
| IABTCF_PublisherLegitimateInterests | Encoded string representing publisher legitimate interests |
| IABTCF_PublisherCustomPurposesConsents | Encoded string representing publisher custom purposes consents |
| IABTCF_TCString | TC string containing the encoded user consent data |
| IABTCF_UseNonStandardTexts | Indicates if non-standard text versions are used (0 = no, 1 = yes) |
| IABTCF_PolicyVersion | IAB TCF policy version number |
| IABTCF_PurposeConsents | Encoded string representing purpose consents |
| IABTCF_PurposeLegitimateInterests | Encoded string representing purpose legitimate interests |
| IABTCF_CmpSdkID | CMP SDK ID |
| IABTCF_CmpSdkVersion | CMP SDK version |
| IABTCF_PublisherCustomPurposesLegitimateInterests | Encoded string representing publisher custom purposes legitimate interests |