iOS

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.

ConstructorDescription
TrustArc.sharedInstanceSingleton entry point used to configure and interact with the SDK.

Initialization Methods

MethodSignatureDescription
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

MethodSignatureDescription
addSdkInitializationDelegate@MainActor @objc public func addSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArcAdds an SDK initialization delegate (multi-delegate pattern).
removeSdkInitializationDelegate@MainActor @objc public func removeSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArcRemoves an SDK initialization delegate.
setSdkInitializationDelegate@MainActor @objc public func setSdkInitializationDelegate(_ delegate: TADelegate) -> TrustArcDeprecated single-delegate setter retained for backward compatibility.

Consent Management Methods

MethodSignatureDescription
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

MethodSignatureDescription
getStoredConsentData@objc public func getStoredConsentData() -> [String: Any]Retrieves stored consent data.
isConsentPresent@objc public func isConsentPresent() -> BoolReturns true if consent data is present.
getStoredConsentExpiry@objc public func getStoredConsentExpiry() -> String?Retrieves stored consent expiry timestamp (if available).
getWebScript@objc public func getWebScript() -> StringRetrieves web script that loads stored preferences into web Consent Manager.
getTcfString@objc public func getTcfString() -> StringRetrieves stored TCF string.
getGoogleConsents@objc public func getGoogleConsents() -> StringRetrieves stored Google Consent Mode data.
getConsentValue@objc public func getConsentValue(trackerId: String) -> StringRetrieves consent value for a specific tracker/domain.
getTrustArcDeviceUUID@objc public func getTrustArcDeviceUUID() -> StringRetrieves TrustArc device UUID.
getConsentLanguage@objc public func getConsentLanguage() -> StringRetrieves 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) -> BoolChecks 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

MethodSignatureDescription
setMode@objc public func setMode(_ sdkMode: SdkMode) -> TrustArcSets SDK mode (standard or iabTCFv_2_2).
setDomain@objc public func setDomain(_ domain: String) -> TrustArcSets domain.
setDomain@objc public func setDomain(_ domain: String, language: String) -> TrustArcSets domain and language.
setLanguage@objc public func setLanguage(_ language: String) -> TrustArcSets language.
setCountry@objc public func setCountry(_ country: String) -> TrustArcSets the country override.
setPrivacyPolicy@objc public func setPrivacyPolicy(_ privacyPolicyLink: String) -> TrustArc(DEPRECATED) Sets the privacy policy link.
enableAppTrackingTransparencyPrompt@objc public func enableAppTrackingTransparencyPrompt(_ enable: Bool) -> TrustArcEnables/disables ATT prompt handling.
setIsTrackingEnabled@objc public func setIsTrackingEnabled(_ isTrackingEnabled: Bool) -> TrustArcSets current tracking-enabled state.
useGdprDetection@objc public func useGdprDetection(_ useGdprDetection: Bool) -> TrustArcDeprecated override for GDPR detection behavior.
setAutomaticUserConsentRefresh@objc public func setAutomaticUserConsentRefresh(_ enabled: Bool) -> TrustArcEnables/disables automatic user-consent refresh.
setImpliedBehaviorEnabled@objc public func setImpliedBehaviorEnabled(_ enabled: Bool) -> TrustArcDeprecated. Enables/disables implied behavior mode.

Delegate Registration Methods

MethodSignatureDescription
addConsentViewControllerDelegate@MainActor @objc public func addConsentViewControllerDelegate(_ delegate: TAConsentViewControllerDelegate) -> TrustArcAdds consent view controller delegate.
removeConsentViewControllerDelegate@MainActor @objc public func removeConsentViewControllerDelegate(_ delegate: TAConsentViewControllerDelegate) -> TrustArcRemoves consent view controller delegate.
addGoogleConsentDelegate@MainActor @objc public func addGoogleConsentDelegate(_ delegate: TAGoogleConsentsDelegate) -> TrustArcAdds Google consent delegate.
removeGoogleConsentDelegate@MainActor @objc public func removeGoogleConsentDelegate(_ delegate: TAGoogleConsentsDelegate) -> TrustArcRemoves Google consent delegate.
addReportingDelegate@MainActor @objc public func addReportingDelegate(_ delegate: TAConsentReporterDelegate) -> TrustArcAdds consent reporter delegate.
removeReportingDelegate@MainActor @objc public func removeReportingDelegate(_ delegate: TAConsentReporterDelegate) -> TrustArcRemoves consent reporter delegate.

Debug and Testing Methods

MethodsDescriptionParametersReturn
enableDebugLogEnables/disables SDK debug logs.enabled: BoolTrustArc
UnifiedConsentAuth.generateHmacAuthIdTesting-only helper to generate HMAC auth id for unified consent workflows.userId: String, key: StringString?

Unified Consent

MethodSignatureDescription
setUnifiedConsentContextsetUnifiedConsentContext(key: String) -> TrustArcContext key only; domain resolved from start().
setUnifiedConsentIdentitysetUnifiedConsentIdentity(userId: String, hmac: String) -> TrustArcStores identity for unified consent.
clearUnifiedConsentContextclearUnifiedConsentContext()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.

FieldDescription
IABTCF_PurposeOneTreatmentIndicates if Purpose One has special treatment (0 = no, 1 = yes)
IABTCF_VendorConsentsEncoded 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_PublisherCCPublisher's country code (e.g., "DE", "FR")
IABTCF_PublisherConsentEncoded string representing publisher-specific consent
IABTCF_gdprAppliesIndicates if GDPR applies (0 = no, 1 = yes)
IABTCF_SpecialFeaturesOptInsEncoded string representing special feature opt-ins
IABTCF_VendorLegitimateInterestsEncoded string representing vendor legitimate interests
IABTCF_PublisherLegitimateInterestsEncoded string representing publisher legitimate interests
IABTCF_PublisherCustomPurposesConsentsEncoded string representing publisher custom purposes consents
IABTCF_TCStringTC string containing the encoded user consent data
IABTCF_UseNonStandardTextsIndicates if non-standard text versions are used (0 = no, 1 = yes)
IABTCF_PolicyVersionIAB TCF policy version number
IABTCF_PurposeConsentsEncoded string representing purpose consents
IABTCF_PurposeLegitimateInterestsEncoded string representing purpose legitimate interests
IABTCF_CmpSdkIDCMP SDK ID
IABTCF_CmpSdkVersionCMP SDK version
IABTCF_PublisherCustomPurposesLegitimateInterestsEncoded string representing publisher custom purposes legitimate interests