API Reference [ Will be deleted]

OneTrust iOS SDK Public Methods

OneTrust SDK Setup Helpers

Existing

Starting OneTrust SDK Setup

Starts the OneTrust SDK, downloads and parses the data and returns the response required to setup OneTrust SDK.

OTPublishersHeadlessSDK.shared.startSDK(storageLocation:, domainIdentifier:, languageCode:, params:, loadOffline:, completionHandler:)

Parameters

  • storageLocation: Contains the storage location from where data has to be fetched (ex: "cdn.cookielaw.org").
  • domainIdentifier: Contains unique Domain Identifier to be passed (ex: "5376c4e0-8367-450c-8669-a0d41bed69ac").
  • languageCode: Contains valid ISO Language code for language for which localized data has be fetched (ex: "en").
  • params: Optional parameter containing additional SDK parameters like country, region code, profile parameters etc.
  • loadOffline: Sets up the OT SDK using offline data that is set via API setOTOffileData(_:). By default this value will be set to false.
  • completionHandler: The block of code that will be triggered once the startSDK setup is complete. Completion Handler contains response object that contains either the server response in the form of a string or an error object if in case the call has failed.

Note: This call would fail if there are internet connectivity issues, invalid storage url/domain-Identifier/language-code is passed.

Note: If the application wants to determine if OneTrust UI should be shown or not and based on that if OneTrust itself has to show the UI, please call setupUI(_:, UIType:) prior to calling this method.

Determine if OneTrust SDK should be shown

Determines whether the OneTrust SDK UI should be shown based on the user's location and whether the user has already provided consent. If consent has been given previously, the UI will not be displayed.

OTPublishersHeadlessSDK.shared.shouldShowBanner()

Returns

  • true - banner should be shown
  • false - banner will not be shown based on user's geolocation / consent has already been given.

OTPublishersHeadlessSDK.shared.showPreferenceCenterUI()

Enabling Logging for OneTrust SDK

Use this API to set the logging level of the OT SDK.

Parameter:

  • level: Log level which has to be printed on console.
    • Values: .noLogs, .error, .warning, .info, .debug, .verbose.

Note: For any valid logLevel passed SDK will log that level and above level. For instance: If level .info is passed, then error, warning and info logs will be printed.

OTPublishersHeadlessSDK.shared.enableOTSDKLog(_:)

Writing OneTrust logs to File

Use this API to write logs to the log file created and maintained by OT SDK.

OTPublishersHeadlessSDK.shared.writeLogsToFile(_:debugLog:)

Parameters:

  • enable: enable write logs to file.
  • debugLog: enable write debug logs to file. Default status is false.

Set Environment for OneTrust worker

This API will set the environment of the OT SDK worker configuration.

Parameter:

  • environment: The environment for which the application should be set up for.
  • Values: dev, qa or prod.
OTPublishersHeadlessSDK.shared.setEnviroment(_:)

Note: By default, the environment is set to production.

Clearing OneTrust SDK data

This API will clear all OneTrust SDK data by removing stored UserDefaults, resetting user consent, and resetting all public method values to defaults.

OTPublishersHeadlessSDK.shared.clearOTSDKData()

Set Custom data download URL

This API will set the URL used for fetching the OT SDK data.

Parameter:

  • urlString: URL string value.
OTPublishersHeadlessSDK.shared.setFetchDataURL(_:)

Reading existing Banner Data

Retrieves all the data needed to construct the OT SDK Banner UI.

Note: The keys will not be the same when CMP API is enabled vs disabled.

OTPublishersHeadlessSDK.shared.getBannerData() -> [String: Any]?

Reading existing Preference Center Data

Retrieves all the data needed to construct the OT SDK Preference Center UI.

Note: The keys will not be the same when CMP API is enabled vs disabled.

OTPublishersHeadlessSDK.shared.getPreferenceCenterData() -> [String: Any]?

New (Starting 202504.1.0)

Fetching and reading Banner Data from CMP API flow

This method can be used to trigger a network call to download Banner data from CMP API.

Parameter

  • completion: The completion contains the banner response represented as a dictionary.

Note: If the data is already fetched, the network call will not be made.

OTPublishersHeadlessSDK.shared.fetchBannerCmpApiData(completion:)

Fetching and reading Preference Center Data from CMP API flow

This method can be used to trigger a network call to download Preference Center data from CMP API.

Parameter

  • completion: The completion contains the Preference Center response represented as a dictionary.

Note: If the data is already fetched, the network call will not be made.

OTPublishersHeadlessSDK.shared.fetchPreferencesCmpApiData(completion:

Fetching and reading Vendors Data from CMP API flow

This method retrieves the Vendors data from the CMP API.

Parameter

  • completion: The completion contains the Vendors response represented as a dictionary.

Note: If the data is already fetched, the network call will not be made.

OTPublishersHeadlessSDK.shared.fetchVendorsCmpApiData(completion:)

Deprecated (starting 202504.1.0)

Get Domain Group Data

Retrieves the domain data that is part of culture data in the form of a dictionary.

Note: Please make sure that the OT SDK data is downloaded at least once prior to making this API call.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please refer to the new list of public methods exposed as domain data will no longer be available directly. We will be exposing individual items that are necessary under domain data via new public methods.

OTPublishersHeadlessSDK.shared.getDomainGroupData() -> [String: Any]?

Get Common Data

Retrieves the common data that is part of culture data in the form of a dictionary.

Note: Please make sure that the OT SDK data is downloaded at least once prior to making this API call.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please refer to the new list of public methods exposed as common data will no longer be available directly. We will be exposing individual items that are necessary under common data via new public methods.

OTPublishersHeadlessSDK.shared.getDomainInfo() -> [String: Any]?

Get Domain Info

Retrieves domain data in the form of a dictionary.

Note: Please make sure that the OT SDK data is downloaded atleast once prior to making this API call.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please refer to the new list of public methods exposed as domain information will no longer be available directly. We will be exposing individual items that are necessary under domain information data via new public methods.

OTPublishersHeadlessSDK.shared.getDomainInfo() -> [String: Any]?

OneTrust UI Helpers

Existing

Setting up OneTrust SDK UI (call before startSDK)

This API sets up the OT SDK UI and checks if the UI needs to be shown and presents the UI based on this check.

Call this method on application's main view controller.

Note: This API uses the shouldShowBanner logic to determine if the OT SDK UI should be shown to the user.

Parameters:

  • viewController: The View Controller of the application on which the OT SDK UI will be presented.
  • UIType: Represents the various types of OT SDK UI that can be presented using this API. Whatever type is passed here, will be displayed if the conditions are satisfied. If the app does not want to show OT SDK UI, then skip this parameter or pass in .none.

Display Banner UI

This API displays the OneTrust SDK Banner UI. It should be called only after the setupUI() method has been executed at least once during the current application session and the OneTrust SDK data has been successfully downloaded. This method does not consider the value of shouldShowBanner.

OTPublishersHeadlessSDK.shared.showBannerUI()

Display Preference Center UI

This API displays the OneTrust SDK Preference Center UI. It should be called only after the setupUI() method has been executed at least once during the current application session and the OneTrust SDK data has been successfully downloaded. This method does not consider the value of shouldShowBanner.

OTPublishersHeadlessSDK.shared.showPreferenceCenterUI()

Adding Event listeners for UI events from OneTrust

This API adds an event listener to OT SDK UI.

Parameter

  • eventListener: Pass any object that conforms to OTEventListener, where you want to listen to events with regards to OT SDK UI.

Note:The object being passed should conform to OTEventListener. Otherwise this listener will not be set.

OTPublishersHeadlessSDK.shared.addEventListener(_:)

Dismiss OneTrust UI

This API dismisses the OT SDK UI if the UI is already present in the view hierarchy.

OTPublishersHeadlessSDK.shared.dismissUI()

Checking if OneTrust UI is currently displayed

Returns a boolean indicating if OT SDK is currently displaying its view in the current view hierarchy.

OTPublishersHeadlessSDK.shared.sdkViewsCurrentlyPresented() -> Bool

Check if OneTrust UI was ever presented

Determines if OT SDK Banner/Preference center was presented to user at least once. This method will support only if SDK UI methods are used.

Returns:

  • -1: if SDK not initialized yet.
  • 0: if Banner/Preference Center was not shown yet (implied consent).
  • 1: if Banner/Preference Center shown.
  • 2: if consent taken using profile syncing

OneTrust SDK Other Helpers

Existing

Saving Consent for OneTrust

Saves the consent of the application based on the interaction type passed, and triggers notifications for the same.

Parameters:

  • type: The interaction type associated with the consent.
  • completion: The completion handler that gets called once the saving is complete.
OTPublishersHeadlessSDK.shared.saveConsent(type:, completion:)

Note: Consent will not be logged to server when interaction type is preference center close.

Note: consent will not logged to server when there are ATT linked categories and ATT permission is not determined.

Reset Local consent

This API will reset the local consents of the Categories, Purposes, Vendors and SDKs.

OTPublishersHeadlessSDK.shared.resetUpdatedConsent()

Adding Custom Data elements for consent logging

This API appends and stores the custom data elements which will be used while logging consent.

Parameter:

  • dataElements: The custom data Elements which will be used while logging consent.
OTPublishersHeadlessSDK.shared.appendCustomDataElements(dataElements:)

Sending consent from Mobile/CTV SDK to Webview/Web SDK

This API retrieves the OT SDK consent string that can be injected using javascript in a webview.

OTPublishersHeadlessSDK.shared.getOTConsentJSForWebView() -> String?

Note: To avoid reconsent prompt in webview, inject this string using javascript before launching the webview.

Fetching values for OneTrust SDK data keys

Returns the value stored in OT SDK that is associated with the passed in key.

Parameter:

  • key: The key for which the value has to be returned.
OTPublishersHeadlessSDK.shared.getValue(forKey:) -> Any?

Google Consent Mode Data

Public method to get Google Consent Mode status.

OTPublishersHeadlessSDK.shared.getOTGoogleConsentModeData() -> OTGoogleConsentModeDataModel

Returns:

  • Retrieves the OTGoogleConsentModeDataModel object. Variable otSDKStatus will return the OneTrust SDK status and variable consentType will return consent mode of GCM consent types.

Get Last Downloaded Location

Returns the last location where the data was last downloaded.

OTPublishersHeadlessSDK.shared.getLastDataDownloadedLocation() -> OTGeolocationModel

Returns:

  • GeolocationModel containing country, state.

Note: If data is not downloaded yet, this method will return a default geo location.

Get Last User Consented Location

Returns the last location where the user has last provided consent.

OTPublishersHeadlessSDK.shared.getLastUserConsentedLocation() -> OTGeolocationModel?

Returns:

  • GeolocationModel containing country, state.

Note: If the user has not consented yet, this method will return nil.

Deprecated

Opt Out of Sale of Data

This API will opt-out of sale of data if the CCPA value is already initialized.

OTPublishersHeadlessSDK.shared.optOutOfSaleOfData(completion:)

Parameter:

  • completion: The completion handler that gets called once the opt-out for sale of data is complete.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, we will no longer be supporting updating of CCPA string via public methods.

Opt In to Sale of Data

This API will opt-in for sale of data if the CCPA value is already initialized.

OTPublishersHeadlessSDK.shared.optIntoSaleOfData(completion:)

Parameter:

  • completion: The completion handler that gets called once the opt-in for sale of data is complete.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, we will no longer be supporting updating of CCPA string via public methods.

Category Purpose Helpers

Existing

Get saved consent for a group

Retrieves the saved consent value for specified group (purpose/category) identifier

Parameter:

  • categoryId: The group represented as a string, for which consent value has to be returned.
OTPublishersHeadlessSDK.shared.getConsentStatus(forCategory:) -> Int8

Returns:

  • 1 = Consent is given
  • 0 = Consent is not given
  • -1 = Consent has not been collected (The SDK is not initialized or category does not exist OR there are no SDKs associated to this category)

Note: This status is not the most update status present in the OneTrust SDK as the consent could be updated locally and not synced yet. Please use getPurposeConsentLocal for fetching the latest consent status.

Get latest local consent for a category

Retrieves the local (saved or unsaved) consent value for specified group identifier.

Parameters:

  • customGroupId: The group represented as a string, for which consent value has to be retrieved.
  • useCmpApi: Retrieves the status from the CMP API data available.
OTPublishersHeadlessSDK.shared.getPurposeConsentLocal(forCustomGroupId:) -> Int8

Returns:

  • 1 = Consent is given
  • 0 = Consent is not given
  • -1 = Consent has not been collected (The SDK is not initialized or category does not exist OR there are no SDKs associated to this category)

Note: Use this API to retrieve the most current consent value (this can be an unsaved value if save operation is not performed yet after toggling the status). Please use getConsentStatus(forCategory:) if you want to retrieve only the last saved value for a category/purpose.

Get saved Legitimate Interest status for a group

Retrieves the legitimate interest value for specified group identifier.

Parameter:

  • customGroupId: The group represented as a string, for which legitimate interest value has to be retrieved.
  • useCmpApi: Retrieves the status from the CMP API data available.
OTPublishersHeadlessSDK.shared.getPurposeLegitInterestLocal(forCustomGroupId:) -> Int8

Returns:

  • 1 = legitimate interest is given
  • 0 if legitimate interest not given
  • \ -1 invalid groupId passed.

Update consent for a group

Updates the consent value for the passed in group identifier.

Parameters:

  • groupId: The group represented as a string, for which consent value has to be updated.
  • consentValue: Boolean value specifying updated consent value.
  • updateHierarchy: If set to true, this will update the hierarchy of the category ID (parents/siblings/children). This value will be false by default.
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: , consentValue: Bool, updateHierarchy:)

Note: If the purpose/category passed is linked with ATT and ATT permission is not granted, update of consent will not be permitted.

Note: Once this operation is complete, a notification will be posted with the updated consent value.

Update Legitimate Interest for a group

Updates the legitimate interest value for the passed in group (purpose/category) identifier.

Parameters:

  • groupId: The group represented as a string, for which legitimate interest value has to be updated.
  • legIntValue: Boolean value specifying updated legitimate interest value.
OTPublishersHeadlessSDK.shared.updatePurposeLegitInterest(forGroup groupId: String, legIntValue: Bool)

Note: Once this operation is complete, a notification will be posted with the updated legitimate interest value.

Get total vendor count for a group

Method to get vendor count configured for a particular purpose.

Parameter:

  • categoryId: String, group id for which vendors have been assigned to. It can be a parent group id like Stack or an individual group like an IAB purpose.
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory:) -> Int

Returns an integer for number of vendors, -1 for error cases.

New (starting 202504.1.0)

Get all parent (root level) groups setup in the OneTrust template

Retrieves all the parent purpose groups that will be displayed in the Preference Center UI.

OTPublishersHeadlessSDK.shared.getAllParentPurposes() -> [PurposeTreeGroup]?

Note: Each parent purpose group will also contain any associated children (if any).

First Party SDK Helpers

Existing

Get latest consent associated with the first party SDK

Retrieves the latest consent value for specified SDK identifier.

Parameter:

  • sdkId: The SDK identifier represented as a string, for which value has to be return.
OTPublishersHeadlessSDK.shared.getConsentStatus(forSDKId:) -> Int8

Returns:

  • Returns the consent status of the passed in SDK identifier.

New (starting 202504.1.0)

Get list of all first party SDKs present in OneTrust SDK

Retrieves all the first party SDKs associated with all the purpose groups that get displayed in Preference Center UI.

OTPublishersHeadlessSDK.shared.getAllFirstPartyCookies() -> [FirstPartyCookiesData]

Note: This list contains all the first party SDKs including the ones that are associated with the children of parent purpose groups.

Vendors Helpers

Existing

Group consent action for all vendors based on mode

Updates consent status for all the vendors locally, based on the mode passed.

Parameters:

  • isSelected: Pass true/false to update all vendor consent to 1/0 locally.
  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.
OTPublishersHeadlessSDK.shared.updateAllVendorsConsentLocal(\_:, for:)

Update consent for an individual vendor

Updates the consent status for a specific vendor locally.

Parameters:

  • vendorID: The vendor identifier for which the consent status needs to be updated.
  • consentStatus: Updated consent status.
  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.
OTPublishersHeadlessSDK.shared.updateVendorConsent(vendorID:, consentStatus:, for:)

Update legitimate interest for an individual vendor

Updates the legitimate interest status for the specified vendor.

Parameters:

  • vendorID: The vendor identifier for which the LI status needs to be updated.
  • legIntStatus: Updated legitimate interest status.
  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.
OTPublishersHeadlessSDK.shared.updateVendorLegitInterest(vendorID:, legIntStatus:, for:) {

Note: Legitimate interest is supported only for IAB vendors.

New (from 202504.1.0)

Get UI styling associated with Vendors List UI

Retrieves all the Vendor List and Vendor Details UI styling related data.

OTPublishersHeadlessSDK.shared.getVendorsListUIStylingData()

Note: The general property will contain all the vendor list UI data and the detailsUIData will contain all the vendor details related UI Data.

Get all active vendors and their details associated with a mode

Returns all the active vendors associated with the passed in mode using CMP API Data.

Parameters:

  • mode: The vendor mode for which the vendors need to be retrieved.

Returns:

  • List of dictionaries where key represents the vendor identifier and the value represents the vendors protocol.
OTPublishersHeadlessSDK.shared.getAllVendors(mode:) -> [String: VendorsInfoProtocol]?

Note: The vendors protocol can be type casted as publicly exposed IAB/Google/General vendors from OTSDK for more individual properties specific to the vendor type.

Get details of an individual vendor

Retrieves all the vendor details associated with the passed in vendor identifier and the vendor mode.

Parameters:

vendorId: The vendor identifier for which the details need to be retrieved.

mode: The vendor mode associated with the vendor (IAB/Google/General).

OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId:, for:) -> VendorsInfoProtocol?

Return:

  • A vendor protocol which can be type casted as publicly exposed IAB/Google/General vendors from OTSDK for more individual properties specific to the vendor type.

Deprecated (starting 202504.1.0)

Retrieves all the active vendors associated with the passed in mode

OTPublishersHeadlessSDK.shared.getVendorListData(for:) -> [String : Any]?

Parameter:

  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please use getAllVendors(mode:) to get all the active vendors associated with the passed in mode.

Retrieves the local state of all the active vendors belonging to the passed in mode.

Parameter:

  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.
OTPublishersHeadlessSDK.shared.getVendorListUI(for:) -> [String : Any]?

Return:

  • A dictionary containing local state of active Vendor List if values are updated without save using updateVendorConsent/updateVendorLegitInterest.
  • Saved Vendor state stored if nothing changed.
  • Nil if none found.

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please use getAllVendors(mode:) to get all the active vendors associated with the passed in mode.

Retrieves all the vendor details for given vendor id and given vendor mode.

Parameter:

  • vendorID: The vendor identifier for which the details needs to be retrieved.
  • mode: The mode of the Vendor List. If no mode is passed, we will consider it as IAB by default.
OTPublishersHeadlessSDK.shared.getVendorDetails(vendorID:, for:) -> [String : Any]?

Deprecation Message: This method will be removed in a couple of releases. Moving forward, please use getVendorDetails(for:mode:) to get the vendor details associated with the passed in vendor identifier.

Multi Profile

Existing

Check currently active profile

Represents the current active profile identifier (data subject identifier).

OTPublishersHeadlessSDK.shared.currentActiveProfile

Delete a profile

Deletes the profile and its associated storage from OT SDK.

OTPublishersHeadlessSDK.shared.deleteProfile(\_:, completion:)

Parameters:

  • profileID: The identifier of the profile to be deleted.
  • completion: The completion block that will be triggered after deleting a profile.

Note: Please make sure that startSDK call is complete before calling this API.

Rename a profile (moving from one DSID to another)

Renames the profile storage from the current profile identifier to the new one.

Parameters:

  • currentProfileID: The current identifier of the profile. If no profile identifier is passed, current profile identifier will be updated to new identifier.
  • newProfileID: The new identifier to which the profile ID should be changed to.
  • completion: Completion block that will be triggered once the rename operation is complete. The boolean status determines if the renaming was successful or not.
OTPublishersHeadlessSDK.shared.renameProfile(from:, to:, withIdentifierType:, completion:)

Note: Please make sure that startSDK call is complete before calling this API.

Switching between multiple profiles

Switches the profile based on the identifier passed.

Parameters:

  • profileID: The identifier of the profile to be loaded.
  • completion: The completion block that will be triggered at the end of the profile switch operation.
OTPublishersHeadlessSDK.shared.switchProfile(to: String, completion:)

Note: Please make sure that startSDK call is complete before calling this API. Additionally if data is missing, SDK will throw an error.

Universal Consent Purposes

Existing

Display OneTrust UCP UI

This API will display the OT SDK Consent Purposes UI.

OTPublishersHeadlessSDK.shared.showConsentPurposesUI(\_:)

Please call this method only after setupUI() method has been called at least once in the current app launch. Make sure that the OT SDK Data is downloaded prior to calling this API.

Note: This method doesn't consider value of shouldShowBanner.

Updating consent for individual UC purpose

Public function to update consent status for specified UCP purpose id.

Parameters:

  • purposeId: String purpose Id for which consent status should be change.
  • value: Boolean value specifying updated consent value (true or false)
OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(purposeId:, withConsent:)

Updating consent for individual custom preference associated with an UC purpose

Public function to update consent status for specified UCP custom preference option id.

OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(cpOptionId:, cpId:, purposeId:, withConsent:)

Parameters:

  • cpOptionId: String custom preference option id for which consent status should be change.
  • cpId: String custom preference id related with custom preference option id.
  • purposeId: String purpose id related with custom preference id.
  • value: Boolean value specifying updated consent value (true or false)

Get consent status of a UC Purpose

Public function to get consent status for specified UCP purpose id.

Parameter:

  • purposeID: String purpose Id for which consent status will be returned.
OTPublishersHeadlessSDK.shared.getUCPurposeConsent(purposeID:) -> Int

Return:

  • 1 = consent given
  • 0 = consent not given
  • -1 = if invalid purpose ID is passed

Get consent status of a custom preference associated with an UC Purpose

Public function to get consent status for an Option of the Custom preference under a given UCPurpose.

Parameters:

  • customPreferenceOptionID: String Option ID under a given custom preference for which consent status will be returned.
  • customPreferenceID: String custom preference id to which Option ID belongs to.
  • purposeID: String purpose id of the custom preference, to which the given Option ID belongs to.
OTPublishersHeadlessSDK.shared.getUCPurposeConsent(customPreferenceOptionID:, customPreferenceID:, purposeID:) -> Int

Return:

  • 1 = if consent given
  • 0 = if consent not given
  • -1 if invalid customPreferenceOptionID/customPreferenceID/purposeID is passed.

New (starting 202504.1.0)

Download OneTrust UCP data

This method retrieves the UC Purposes data from the CMP API.

Parameter:

  • completion: The completion contains the UCP response represented as a dictionary.

Note: If the data is already fetched, the network call will not be made.

OTPublishersHeadlessSDK.shared.fetchUCPurposesCmpApiData(completion:)

Deprecated (starting 202504.1.0)

Update consent status for UCP Topic Option ID

Public function to update consent status for specified UCP topic option id.


Parameters:

  • topicOptionId: String topic option id for which consent status should be change.
  • purposeId: String purpose id related with specified topic option id for which consent status should be change.
  • value: Boolean value specifying updated consent value (true or false)
OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(topicOptionId:, purposeId:, withConsent:)

Deprecation Message: Topics have now been deprecated in UCP.

Get consent status for UCP Topic Option ID

Public function to get consent status for specified UCP purpose id.

Parameters:

  • purposeID: String purpose Id for which consent status will be returned.

Return:

  • 1 = if consent given
  • 0 = if consent not given
  • -1 = if invalid purpose ID is passed
OTPublishersHeadlessSDK.shared.getUCPurposeConsent(topicID:, purposeID:) -> Int

Deprecation Message: Topics have now been deprecated in UCP.

Prompts

Existing

showConsentUI

Displays prompt UI configured in OneTrust Template associated with the application ID. Shows the view for getting user consent for the passed in permission type.

Parameter:

  • permissionType: The application permission type.
  • presenter: The controller on which the permission consent should be presented.
  • completion: This block will be triggered once the consent action is taken by the user and the consent view is closed.
OTPublishersHeadlessSDK.shared.showConsentUI(for:, from:, completion:)

Notes:Please make sure that the OT data is downloaded via startSDK API prior to calling this method.The UI would only show up if its configured at the template level else we will see an error logged by OneTrust SDK indicating the same.

Checking if consent for the permission prompt has changed and logging consent with OneTrust

Determines if the passed in permissionType consent status has changed and if it did, updates the new value to Consent Logging API.

CustomConfigurator.checkAndLogConsent(for:)

Parameter:

  • permissionType: The permission type for which consent needs to be logged.

Notes:Please make sure that the OT data is downloaded via startSDK API prior to calling this method.Consent logging will only be performed if the passed in permission prompt is configured at the template.
Currently we only support logging consent for App Tracking Transparency.

Proxy

Existing

Setting up delegate for the Proxy configuration

Set this delegate in order to customize configurations w.r.t OT SDK business logic like setting up Proxy configuration for OneTrust network calls.

OTPublishersHeadlessSDK.shared.customConfigurator

Implementing and providing custom URL for replacing specific OneTrust network call

Conform to this method to provide proxy domain URL for a supported proxy type.

When conformed to this method, we will be hitting the proxy domain provided when required, instead of the actual URL configured within OneTrust.

Parameters:

  • type: The type of Proxy URLs support by OT SDK.
CustomConfigurator.getProxyDomain(for:) -> URL?

Return:

  • A proxy domain for the proxy type.

Proxy Type for Consent Logging network call

Proxy for the URL used for logging consent.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.logConsent(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.logConsent(URL)

Proxy Type for downloading banner logo network call

Proxy for the URL used for downloading banner logo.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.bannerLogo(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.bannerLogo(URL)

Proxy Type for downloading preference center logo network call

Proxy for the URL used for downloading preference center logo.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.pcLogo(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.pcLogo(URL)

Proxy Type for downloading App Tracking Transparency Pre Prompt logo network call

Proxy for the URL used for downloading ATT pre prompt logo.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.attPrePromptLogo(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.attPrePromptLogo(URL)

Proxy Type for downloading App Tracking Transparency Post Prompt logo network call

Proxy for the URL used for downloading ATT post prompt logo.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.attPostPromptLogo(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.attPostPromptLogo(URL)

Proxy Type for downloading Age Gate Prompt logo network call

Proxy for the URL used for downloading Age Gate Prompt logo.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.ageGateLogo(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.ageGateLogo(URL)

New (starting 202504.1.0)

Proxy Type for downloading Banner data via CMP API

Proxy for the URL used for downloading Banner data via CMP API.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.cmpBanner(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.cmpBanner(URL)

Proxy Type for downloading Preferences data via CMP API

Proxy for the URL used for downloading Banner data via CMP API.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.cmpPreferences(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.cmpPreferences(URL)

Proxy Type for downloading Vendors data via CMP API

Proxy for the URL used for downloading Preference Center data via CMP API

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.cmpVendors(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.cmpVendors(URL)

Proxy Type for downloading Vendors data via Cmp Api

Proxy for the URL used for downloading Vendors data via CMP API.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.cmpVendors(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.cmpVendors(URL)

Proxy Type for downloading Universal Center Purposes data via CMP API

Proxy for the URL used for downloading Vendors data via CMP API.

Implementing CustomConfigurator.getProxyDomain(for:) and providing a custom URL for ProxyType.cmpUCPurposes(URL) will make sure OneTrust uses the passed in URL instead of the url that is configured within the SDK.

ProxyType.cmpUCPurposes(URL)

Reading consent associated with Age Gate permission prompt.

Returns the value stored in OT SDK that is associated with the passed in key.

Parameter

  • key: The key for which the value has to be returned.
OTPublishersHeadlessSDK.shared.getAgeGatePromptValue() -> Int

Deprecated (starting 202504.1.0)

Proxy for the URL used for downloading OneTrust SDK data via App Worker

ProxyType.sdkDataDownload(URL)

Deprecation Message: The applications can use the new Cmp Api Proxy Types for fetching respective OneTrust Screens related data (banner/preference center/vendor).

Proxy for the URL used for downloading IAB Vendors data

ProxyType.iabVendors(URL)

Deprecation Message:The applications can use the new Cmp Api Vendors Proxy type for fetching all the vendor information.

Proxy for the URL used for downloading Google Vendors data

ProxyType.googleVendors(URL)

Deprecation Message: The applications can use the new Cmp Api Vendors Proxy type for fetching all the vendor information.

Proxy for the URL used for downloading General Vendors data

ProxyType.generalVendors(URL)

Deprecation Message: The applications can use the new Cmp Api Vendors Proxy type for fetching all the vendor information.

More Details

Saving Consent

Banner Allow All

Call this method when user selects Allow All button on the Banner. This will opt-in the user to all Category/Purposes.

// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .bannerAllowAll)

IAB TCF2

For IAB TCF2 templates, this method also sets the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-in. These values will be encoded into the TC String and saved to UserDefaults.

Banner Reject All

Call this method when user selects Reject All button on the Banner. This will opt-out the user to all Category/Purposes.

// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .bannerRejectAll)

IAB TCF2

For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-out. These values will be encoded into the TC String and saved to UserDefaults.

Banner Close

Call this method when closing the Banner. It will save the default consent values for each Category/Purpose based on the geolocation rule.

// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .bannerClose)

IAB TCF2

For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any). These values will be encoded into the TC String and saved to UserDefaults.

Get Preference Center Data

This method returns a dictionary which contains all the keys required to render a Preference Center.

// Swift
OTPublishersHeadlessSDK.shared.getPreferenceCenterData()

Preference Center Allow All

Call this method when user selects Allow All button on the Banner. This will opt-in the user to all Category/Purposes.

// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .preferenceCenterAllowAll)

IAB TCF2

For IAB TCF2 templates, this method also sets the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-in. These values will be encoded into the TC String and saved to UserDefaults.

Preference Center Reject All

Call this method when user selects Reject All button on the Banner. This will opt-out the user to all Category/Purposes.

// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .preferenceCenterRejectAll)

IAB TCF2

For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-out. These values will be encoded into the TC String and saved to UserDefaults.

Programmatically Update and Save Purpose Consent

These methods are typically utilized in a BYOUI approach and can be used to update and save consent programmatically for a specific category to true or false based on user input. Simply pass in the group/category ID and consent status to update the values.

Usage

Modifying the user's consent is a two step approach. updatePurposeConsent() is used to set the state of the consent (toggles) on the UI and saveConsent() is used to commit and save the consent to local storage. saveConsent MUST be called or consent will NOT be committed and changed.

// Swift
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "C0004", consentValue: true, updateHierarchy: true)
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "C0002", consentValue: false, updateHierarchy: true)
// Swift
OTPublishersHeadlessSDK.shared.saveConsent(type: .preferenceCenterConfirm)

Parameters

  • forGroup - Category/Group ID of the category to be modified (e.g. C0001, C0002, C0004, etc.)
  • consentValue - Consent status given by the user for a category/group. Boolean type.
  • updateHierarchy - Updates the toggle state on the OneTrust UI
  • type - Denotes the type of interaction used to commit/save consent (e.g. banner allow all, preference center confirm, preference center reject, etc.)

Below is a sample implementation on how to update and save if you have multiple categories to update at a time.

// Swift
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "C0004", consentValue: true, updateHierarchy: true)
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "C0005", consentValue: true, updateHierarchy: true)
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "C0006", consentValue: true, updateHierarchy: true)
OTPublishersHeadlessSDK.shared.updatePurposeConsent(forGroup: "IABV2_6", consentValue: true, updateHierarchy: true)
OTPublishersHeadlessSDK.shared.saveConsent(type: .preferenceCenterConfirm)

Reset updated consent values for all Categories

This method resets any updated Category/Purpose consent values to their defaults prior to being saved to disk. Use this method if a user makes updates in their Preference Center but then exits without Saving their choices.

// Swift
OTPublishersHeadlessSDK.shared.resetUpdatedConsent()

More details about Vendors API

Get Vendor List UI

This method will allow your application to retrieve the dictionary required to render the vendor list UI. It returns a dictionary containing local state of active IAB Vendor List if values are updated without save using updateVendorConsent/updateVendorLegitInterest. Returns previously saved IAB vendor state if nothing has changed. Nil if no active vendors are found.

// Swift
OTPublishersHeadlessSDK.shared.getVendorListUI()

Get Vendor List Data

This method will allow your application to retrieve the dictionary required to render the vendor list UI. It returns a dictionary containing saved state of active IAB Vendor List. Returns nil if no active vendors are found.

// Prior to 202504.1.0
OTPublishersHeadlessSDK.shared.getVendorListData()

// 202504.1.0 onwards
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .iab)
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .google)
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .general)

Get Total Vendor Count

This method allows you to return the total number of IAB TCF vendors your app is using. This can be useful in instances where you're building your own banner and need to include the vendor count as required by IAB.

// Prior to 202504.1.0
var allVendors = OTPublishersHeadlessSDK.shared.getVendorListData(for: VendorListMode.iab)
allVendors?.count

// 202504.1.0 onwards
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .iab)?.count
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .google)?.count
OTPublishersHeadlessSDK.shared.getAllVendors(mode: .general)?.count

More details about Groups API

Query Consent Status for a Category

Query the current consent status for any of the Categories included in your application. This can be used to determine what privacy action is needed at app launch or anytime the consent status is needed without being notified by an event broadcast. Simply pass in the Category ID (eg. C0001) and the method will return the current consent status.

// Swift
OTPublishersHeadlessSDK.shared.getConsentStatus(forCategory: "C0002")

Parameters

  • forCategory - Custom group ID contained in the group dictionary returned by SDK public methods. Custom group IDs for each category can be obtained from OneTrust console as well.

Returns

  • 1 = Consent Given
  • 0 = Consent Not Given
  • -1 = Consent has not been collected/ sdk is not yet initialized

Query Consent Status for a Specific SDK

Query the current consent status for any of the SDKs included in your application. This can be used to determine what privacy action is needed at application launch or anytime the consent status is needed without being notified by an event broadcast. Pass in the SDK ID and the method will return the current consent status.

// Swift
OTPublishersHeadlessSDK.shared.getConsentStatus(forSDKId: "2368810c-94da-4f18-ab92-c55c5f74cca9")

// ObjC
[OTPublishersHeadlessSDK.shared getConsentStatusForSDKId:@"2368810c-94da-4f18-ab92-c55c5f74cca9"];

Parameters

  • SDK GUID - SDK ID contained in the group dictionary returned by SDK public methods. SDK IDs for each SDK configured in the application can be obtained from OneTrust console as well.

Returns

  • 1 = Consent Given
  • 0 = Consent Not Given
  • -1 = Consent has not been collected

Set Data Subject Identifier

This method sets the identifier for the User Profile the consent is being saved to.

  • When the identifier is not set, the SDK will generate a unique (anonymous) identifier by default.
Requires SDK Init?Yes
MethodOTPublishersHeadlessSDK.shared.renameProfile(from: "currentProfileID", to: "newProfileID",completion: { renameSuccess in print(renameSuccess) } )
Argumentsid: string

After renaming the user ID, you must pass the identifier into OTProfileSyncParams and startSDK.

OTPublishersHeadlessSDK.shared.renameProfile(to: "[email protected]") { Bool in
    print("Rename complete")
}

let sdkParams = OTSdkParams(countryCode: nil, regionCode: nil)
let profileSyncParams = OTProfileSyncParams()
profileSyncParams.setIdentifier(OTPublishersHeadlessSDK.shared.currentActiveProfile)
sdkParams.setProfileSyncParams(profileSyncParams)


OTPublishersHeadlessSDK.shared.startSDK(storageLocation: cdnLocation, domainIdentifier: appID,
                                        languageCode: lang,
                                        params: sdkParams) { [weak self] response in
                                        
      guard let self = self, let _ = response.error else { return }
      print("Current DSID = \(OTPublishersHeadlessSDK.shared.currentActiveProfile)")
}

Get Data Subject Identifier

This method returns the Data Subject ID saved by the SDK. You can use this value to lookup Consent Receipts for a User on the OneTrust Admin.

Requires SDK Init?Yes
MethodOTPublishersHeadlessSDK.shared.currentActiveProfile
Argumentsn/a
Returnsstring

Multi Profile Consent

The following methods can be used to support multi profile consent for your application if you allow multiple user profiles to use one login.

  • Use the following method to allow users to switch profiles so that consent profile of the current user is saved and profile for the new user is retrieved from user defaults.
OTPublishersHeadlessSDK.shared.switchProfile(to "profileIDToBeSwitchedTo", completion: {profileSwitchError in print(profileSwitchError ?? "Profile Switch Successful.") } )
  • Use the following method to allow you to rename a user's profile.
OTPublishersHeadlessSDK.shared.renameProfile(from: "currentProfileID", to: "newProfileID",completion: { renameSuccess in print(renameSuccess) } ) 
  • Use the following method to delete a user's profile.
OTPublishersHeadlessSDK.shared.deleteProfile("profileIDToBeDeleted", completion: { deletionError in print(deletionError ?? "Profile Deletion Successful.") } )
  • Use the following method to retrieve the current profile ID.
OTPublishersHeadlessSDK.shared.currentActiveProfile