The following documentation outlines the APIs available for use in the TrustArc Mobile Consent SDK for iOS.
TrustArc Class
The TrustArc class is the main entry point for interacting with the TrustArc SDK.
| Constructor | Description |
| TrustArc.sharedInstance | Singleton entry point used to configure and interact with the SDK. |
Initialization Methods
| Method | Signature | Description |
| start | @objc public func start(withCompletion completion: @Sendable @escaping (Bool) -> Void) | Starts the TrustArc SDK. The boolean parameter is shouldShowConsentUI (whether app should show consent UI after startup flow). |
| start | @objc public func start(viewController: UIViewController, completion: @Sendable @escaping (Bool) -> Void) | Starts the TrustArc SDK with a specific view controller. The boolean parameter is shouldShowConsentUI. |
SDK Initialization Delegate Methods
| Method | Signature | Description |
| addSdkInitializationDelegate | @MainActor @objc public func addSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArc | Adds an SDK initialization delegate (multi-delegate pattern). |
| removeSdkInitializationDelegate | @MainActor @objc public func removeSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArc | Removes an SDK initialization delegate. |
| setSdkInitializationDelegate | @MainActor @objc public func setSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArc | Deprecated single-delegate setter retained for backward compatibility. |
Consent Management Methods
| Method | Signature | Description |
| openCM | @objc public func openCM(in viewController: UIViewController, delegate: TAConsentViewControllerDelegate?) | Opens the consent manager window in the specified view controller |
| confirmRequiredTrackers | @objc public func confirmRequiredTrackers(in viewController: UIViewController, delegate: TAConsentViewControllerDelegate?) | Confirms required trackers without opening the consent manager window |
Consent Data Methods
| Method | Signature | Description |
| getStoredConsentData | @objc public func getStoredConsentData() -> [String: Any] | Retrieves stored consent data. |
| isConsentPresent | @objc public func isConsentPresent() -> Bool | Returns true if consent data is present. |
| getStoredConsentExpiry | @objc public func getStoredConsentExpiry() -> String? | Retrieves stored consent expiry timestamp (if available). |
| getWebScript | @objc public func getWebScript() -> String | Retrieves web script that loads stored preferences into web Consent Manager. |
| getTcfString | @objc public func getTcfString() -> String | Retrieves stored TCF string. |
| getGoogleConsents | @objc public func getGoogleConsents() -> String | Retrieves stored Google Consent Mode data. |
| getConsentValue | @objc public func getConsentValue(trackerId: String) -> String | Retrieves consent value for a specific tracker/domain. |
| getTrustArcDeviceUUID | @objc public func getTrustArcDeviceUUID() -> String | Retrieves TrustArc device UUID. |
| getConsentLanguage | @objc public func getConsentLanguage() -> String | Retrieves language code used during SDK initialization. |
| getConsentDataByCategory | @objc public func getConsentDataByCategory() -> [String: TAConsent] | Retrieves stored consent grouped by category. |
| isCategoryConsented | @objc public func isCategoryConsented(categoryIndex: Int) -> Bool | Checks whether a specific category index is consented. |
| getCategoryConsent | @objc public func getCategoryConsent(categoryIndex: Int) -> TACategoryConsent? | Retrieves category consent object for a specific category index. |
| getStoredWebConsentData | @objc public func getStoredWebConsentData() -> [String: Any] | Retrieves stored web consent data. |
Configuration Methods
| Method | Signature | Description |
| setMode | @objc public func setMode(_ sdkMode: SdkMode) -> TrustArc | Sets SDK mode (standard or iabTCFv_2_2). |
| setDomain | @objc public func setDomain(_ domain: String) -> TrustArc | Sets domain. |
| setDomain | @objc public func setDomain(_ domain: String, language: String) -> TrustArc | Sets domain and language. |
| setLanguage | @objc public func setLanguage(_ language: String) -> TrustArc | Sets language. |
| setCountry | @objc public func setCountry(_ country: String) -> TrustArc | Sets the country override. |
| setPrivacyPolicy | @objc public func setPrivacyPolicy(_ privacyPolicyLink: String) -> TrustArc | (DEPRECATED) Sets the privacy policy link. |
| enableAppTrackingTransparencyPrompt | @objc public func enableAppTrackingTransparencyPrompt(_ enable: Bool) -> TrustArc | Enables/disables ATT prompt handling. |
| setIsTrackingEnabled | @objc public func setIsTrackingEnabled(_ isTrackingEnabled: Bool) -> TrustArc | Sets current tracking-enabled state. |
| useGdprDetection | @objc public func useGdprDetection(_ useGdprDetection: Bool) -> TrustArc | Deprecated override for GDPR detection behavior. |
| setAutomaticUserConsentRefresh | @objc public func setAutomaticUserConsentRefresh(_ enabled: Bool) -> TrustArc | Enables/disables automatic user-consent refresh. |
| setImpliedBehaviorEnabled | @objc public func setImpliedBehaviorEnabled(_ enabled: Bool) -> TrustArc | Deprecated. Enables/disables implied behavior mode. |
Delegate Registration Methods
| Method | Signature | Description |
| addConsentViewControllerDelegate | @MainActor @objc public func addConsentViewControllerDelegate(_ delegate: TAConsentViewControllerDelegate) -> TrustArc | Adds consent view controller delegate. |
| removeConsentViewControllerDelegate | @MainActor @objc public func removeConsentViewControllerDelegate(_ delegate: TAConsentViewControllerDelegate) -> TrustArc | Removes consent view controller delegate. |
| addGoogleConsentDelegate | @MainActor @objc public func addGoogleConsentDelegate(_ delegate: TAGoogleConsentsDelegate) -> TrustArc | Adds Google consent delegate. |
| removeGoogleConsentDelegate | @MainActor @objc public func removeGoogleConsentDelegate(_ delegate: TAGoogleConsentsDelegate) -> TrustArc | Removes Google consent delegate. |
| addReportingDelegate | @MainActor @objc public func addReportingDelegate(_ delegate: TAConsentReporterDelegate) -> TrustArc | Adds consent reporter delegate. |
| removeReportingDelegate | @MainActor @objc public func removeReportingDelegate(_ delegate: TAConsentReporterDelegate) -> TrustArc | Removes consent reporter delegate. |
Debug and Testing Methods
| Methods | Description | Parameters | Return |
| enableDebugLog | Enables/disables SDK debug logs. | enabled: Bool | TrustArc |
| UnifiedConsentAuth.generateHmacAuthId | Testing-only helper to generate HMAC auth id for unified consent workflows. | userId: String, key: String | String? |
Unified Consent
| Method | Signature | Description |
| setUnifiedConsentContext | setUnifiedConsentContext(key: String) -> TrustArc | Context key only; domain resolved from start(). |
| setUnifiedConsentIdentity | setUnifiedConsentIdentity(userId: String, hmac: String) -> TrustArc | Stores identity for unified consent. |
| clearUnifiedConsentContext | clearUnifiedConsentContext() | Clears unified context + identity. |
TADelegate Protocol
The TADelegate protocol defines methods for handling various states of the SDK initialization and asset downloading process.
@MainActor
@objc public protocol TADelegate: AnyObject {
func sdkIsNotInitialized()
func sdkIsInitializing()
func sdkIsInitialized()
@objc optional func sdkIsInitialized(isInitialized: Bool, message: String?)
@objc optional func sdkIsDownloadingAssets()
@objc optional func sdkDidFinishDownloadingAssets(hasFailed: Bool)
@objc optional func sdkWillStartFetchingUnifiedConsent()
@objc optional func sdkIsFetchingUnifiedConsent()
@objc optional func sdkDidFinishFetchingUnifiedConsent(hasFailed: Bool, message: String?)
@objc optional func sdkDidFinishSavingUserConsent(hasFailed: Bool, message: String?)
}TAConsentViewControllerDelegate Protocol
The TAConsentViewControllerDelegate protocol defines the callback methods on consent data changes.
@MainActor
@objc public protocol TAConsentViewControllerDelegate: AnyObject, Sendable {
/// When the tool's web view is loading
func consentViewController(_ consentViewController: TAConsentViewController,
isLoadingWebView webView: WKWebView)
/// When the tool's web view did finish loading
func consentViewController(_ consentViewController: TAConsentViewController,
didFinishLoadingWebView webView: WKWebView)
/// When the consent tool gets the consent string
func consentViewController(_ consentViewController: TAConsentViewController,
didReceiveConsentData consentData: [String: Any])
/// When the consent tool is dismissed
@objc optional func consentViewControllerDidClose(_ consentViewController: TAConsentViewController)
}TAGoogleConsentsDelegate Protocol
The TAGoogleConsentsDelegate protocol defines a method for updating Google consent data. This is fired when Google Consent Mode (GCM) integration is enabled on the domain.
@objc public protocol TAGoogleConsentsDelegate {
@objc func didUpdateConsentData(consentDict: [NSString : Bool])
}TAConsentReporterDelegate Protocol
The TAConsentReporterDelegate protocol defines methods for handling consent reporting events.
@objc public protocol TAConsentReporterDelegate {
@objc func consentReporterWillSend(report: trustarc_consent_sdk.TAConsentReportInfo)
@objc func consentReporterDidSend(report: trustarc_consent_sdk.TAConsentReportInfo)
@objc func consentReporterDidFailSending(report: trustarc_consent_sdk.TAConsentReportInfo)
}IABTCFPreferences
Type definition for IAB TCF (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 |