iOS

Overview

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 the app should show consent UI after the 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 the 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 the TrustArc device UUID.
getConsentLanguage @objc public func getConsentLanguage() -> String Retrieves the 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 the domain.
setDomain @objc public func setDomain(_ domain: String, language: String) -> TrustArc Sets the domain and language.
setLanguage @objc public func setLanguage(_ language: String) -> TrustArc Sets the 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
Method 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 is resolved from start().
setUnifiedConsentIdentity setUnifiedConsentIdentity(userId: String, hmac: String) -> TrustArc Stores identity for unified consent.
clearUnifiedConsentContext clearUnifiedConsentContext() Clears unified context and 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?)
}
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 for iOS and Android now supports TCF. To ensure proper consent handling, 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.
TrustArc  ·  Mobile App Consent — API Reference: iOS  ·  www.trustarc.com