IAB TCF 2.2

Overview

What Is The Transparency & Consent Framework?

The TCF’s simple objective is to help all parties in the digital advertising chain ensure that they comply with the EU’s GDPR and ePrivacy Directive when processing personal data or accessing and/or storing information on a user’s device, such as cookies, advertising identifiers, device identifiers and other tracking technologies.

TCF v2.2

TCF v2.2 enables consumers to grant or withhold consent and also exercise their ‘right to object’ to data being processed. Consumers also gain more control over whether and how vendors may use certain features of data processing, for example, the use of precise geolocation.

Publishers employing TCF v2.2 gain greater control and flexibility with respect to how they integrate and collaborate with their technology partners. New publisher functionality allows them to restrict the purposes for which personal data is processed by vendors on a publisher’s website on a per-vendor basis.

OneTrust Configuration guidelines

OneTrust helps you to configure the IAB TCF version for your application by building the IAB template in OneTrust’s environment.

Accessing TC Data

Once user gives consent, OneTrust retrieve the TC Data and save it to the iOS’s default UserDefaults based on the IAB version your application is compliant with. Your application can access the data by fetching it using following keys from default UserDefaults.
The TC data values can be retrieved from the application UserDefaults by key name. For the purposes of accessing TC data, only two methods should be necessary:

  • getString(String key, String defValue) for String values
  • getInt(String key, int defValue) for Integer values and representations of Boolean values

IAB TCF Keys

UserDefaults KeyOT Constant
IABTCF_CmpSdkIDOTConstants.IABKeys.iabTcf2CmpSdkId
IABTCF_CmpSdkVersionOTConstants.IABKeys.iabTcf2CmpSdkVersion
IABTCF_gdprAppliesOTConstants.IABKeys.iabTcf2GdprApplies
IABTCF_PolicyVersionOTConstants.IABKeys.iabTcf2PolicyVersion
IABTCF_PurposeOneTreatmentOTConstants.IABKeys.iabTcf2PurposeOneTreatment
IABTCF_UseNonStandardStacksOTConstants.IABKeys.iabTcf2UseNonStandardStacks
IABTCF_SpecialFeaturesOptInsOTConstants.IABKeys.iabTcf2SpecialFeaturesOptIns
IABTCF_PublisherCCOTConstants.IABKeys.iabTcf2PublisherCC
IABTCF_PublisherConsentOTConstants.IABKeys.iabTcf2PublisherConsent
IABTCF_PublisherLegitimateInterestsOTConstants.IABKeys.iabTcf2PublisherLegitimateInterests
IABTCF_PublisherCustomPurposesConsentsOTConstants.IABKeys.iabTcf2PublisherCustomPurposesConsents
IABTCF_PublisherCustomPurposesLegitimateInterestsOTConstants.IABKeys.iabTcf2PublisherCustomPurposesLegitimateInterests
IABTCF_PurposeConsentsOTConstants.IABKeys.iabTcf2PurposeConsents
IABTCF_PurposeLegitimateInterestsOTConstants.IABKeys.iabTcf2PurposeLegitimateInterests
IABTCF_TCStringOTConstants.IABKeys.iabTcf2TCString
IABTCF_VendorConsentsOTConstants.IABKeys.iabTcf2VendorConsents
IABTCF_VendorLegitimateInterestsOTConstants.IABKeys.iabTcf2VendorLegitimateInterests
IABTCF_PublisherRestrictionsOTConstants.IABKeys.iabTcf2PublisherRestrictions

Sample Code Snipet

// Swift
var iabTcfValue : Any?
guard let savedValue = UserDefaults.standard.value(forKey: "IABTCF_CmpSdkID") else {
	iabTcfValue = ""
	return
}
if savedValue is Int {
	iabTcfValue = String(savedValue as! Int)
} else if savedValue is String {
	iabTcfValue = String(savedValue as! String)
}


// ObjC
id iabTcfValue;
id savedValue = [NSUserDefaults.standardUserDefaults valueForKey:@"IABTCF_CmpSdkID"];
if (savedValue) {
	iabTcfValue = (NSString *)savedValue;
} else {
	iabTcfValue = @"";
}

OneTrust provides public constant for accessing IABTCF_CmpSdkID key. Above lines can be written using OneTrust keys as:

// Swift
var iabTcfValue : Any?
guard let savedValue = UserDefaults.standard.value(forKey: OTIABTCFKeys.iabTcf2CmpSdkId) else {
	iabTcfValue = ""
	return
}
if savedValue is Int {
	iabTcfValue = String(savedValue as! Int)
} else if savedValue is String {
	iabTcfValue = String(savedValue as! String)
}


// ObjC
id iabTcfValue;
id savedValue = [NSUserDefaults.standardUserDefaults
valueForKey:OTIABTCFKeys.iabTcf2CmpSdkId];
if (savedValue) {
	iabTcfValue = (NSString *)savedValue;
} else {
	iabTcfValue = @"";
}

Get Vendor Consent

This method returns the details for a specific vendor, including consent value.

IAB Vendor

// example without for: .iab parameter, IAB is default
OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId: 8) 

// example with for: .iab parameter
OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId: 8, for: .iab)

// example for directly getting vendor's consent value
[OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId: 8, for: .iab)?["consent"]

Google Vendor

// must call with for: .google parameter
OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId: 8, for: .google)

// example for directly getting vendor's consent value
[OTPublishersHeadlessSDK.shared.getVendorDetails(vendorId: 8, for: .google)?["consent"]

Get Vendor Count by Purpose

This method returns the vendor count for IAB purposes as required by IAB TCF 2.2. Applications will have to pass in the desired Purpose ID or Stack Number.

//Purposes
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "IAB2V2_1")
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "IAB2V2_2")

//Stacks
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "V2STACK1")
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "V2STACK42")

//Features
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "IFE2V2_1")
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "IFE2V2_2")

//Special Features
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "ISF2V2_1")
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "ISF2V2_2")

//Special Purposes
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "ISP2V2_1")
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "ISP2V2_2")

// Swift
OTPublishersHeadlessSDK.shared.getVendorCount(forCategory: "String")

//ObjC
[OTPublishersHeadlessSDK.shared getVendorCountForCategory:@"String"];

Values Returned

This method will return the Vendor Count as an Integer value. Here are the possible outcomes:

  • Individual categories will have active IAB Vendors count returned
  • Parent categories will have aggregated active IAB Vendors count returned
  • Empty category IDs will return -1 as the Vendor Count

Get Total Vendor Count

This method allows you to return the total number of 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.

var vendorCount = OTPublishersHeadlessSDK.shared.getVendorListData(for: VendorListMode.iab)
vendorCount?.count

Update Vendor Consent

This method will allow your application to update consent value for vendors. Applications will have to pass a valid String value vendor ID along with a boolean state.
Calling this method will only update the local state of consent. To persist the updated values, applications will have to call 'saveConsentValue()' method explicitly.

// Swift
OTPublishersHeadlessSDK.shared.updateVendorConsent(vendorId: "51", consentStatus: true)

// ObjC
[OTPublishersHeadlessSDK.shared updateVendorConsentWithVendorId:@"51" consentStatus:true];

Update Vendor Legitimate Interest

This method will allow your application to update legitimate interest value for Active IAB Vendor. Applications will have to pass a valid String value vendor ID along with a boolean state.
Calling this method will only update the local state of legitimate interest. To persist the updated values, applications will have to call 'saveConsentValue()' method explicitly.
If Legitimate Interests toggles are configured to be disabled for an application, then value will not get updated.

// Swift
OTPublishersHeadlessSDK.shared.updateVendorLegitInterest(vendorId: "51", legIntStatus: true)

// ObjC
[OTPublishersHeadlessSDK.shared updateVendorLegitInterestWithVendorId:@"51" legIntStatus:true];

Update Purpose Legitimate Interest

This method will allow your application to update legitimate interest value for an IAB purpose. Applications will have to pass a valid String value group identifier along with a boolean state.
Calling this method will only update the local state of legitimate interest. To persist the updated values, applications will have to call 'saveConsentValue()' method explicitly.
If Legitimate Interests toggles are configured to be disabled for an application, then value will not get updated.

// Swift
OTPublishersHeadlessSDK.shared.updatePurposeLegitInterest(forGroup: "IAB2V2_3", legIntValue: true)

// ObjC
[OTPublishersHeadlessSDK.shared updatePurposeLegitInterestForGroup:@"IAB2V2_3" legIntValue:true];

Get Locally Saved Purpose Consent

This method will allow your application to retrieve the local consent value for an IAB purpose. Applications will have to pass a valid string value identifier for the purpose you're trying to query for.

OTPublishersHeadlessSDK.shared.getConsentStatus(forCategory: "IAB2V2_1")

Returns the following Integer values:

  • 1 = Consent Given.
  • 0 = Consent Not Given.
  • -1 = Invalid Group Id passed.

Get Locally Saved Purpose Legitimate Interest

This method will allow your application to retrieve the local legitimate interest value for an IAB purpose. Applications will have to pass a valid string value identifier for the purpose you're trying to query for.

// Swift
OTPublishersHeadlessSDK.shared.getPurposeLegitInterestLocal(forCustomGroupId: "IAB2V2_3")

Returns the following Integer values:

  • 1 = Consent Given.
  • 0 = Consent Not Given.
  • -1 = Invalid Group Id passed / Group Id does not have a Legitimate interest configured for it.

Confirm My Choices CTA for the Vendor List

The Confirm My Choices CTA on the Vendor List will be hidden by default. When a user makes changes to vendor consents, they'll have to navigate back to the main Preference Center page to save and commit their choices. You can choose to show/hide the Confirm My Choices CTA on the Vendor List.

Setting the CTA

The app should conform to UIConfigurator and the function getVendorListJourney() added.

OTPublishersHeadlessSDK.shared.uiConfigurator = self

extension AppDelegate:UIConfigurator {
   func shouldUseCustomUIConfig() -> Bool {
   return false
   }

   func getVendorListJourney() -> VendorListJourneyType {
   showConfirmMyChoices
   }

}

This method has two possible parameters:

ParameterDescription
showConfirmMyChoicesSDK UI should be dismissed when Confirm My Choices button is selected
hideConfirmMyChoicesHides the Confirm My Choices button in the Vendor List

FAQ

Does the Mobile CMP support Global Scope?

No, as of the OneTrust 6.22 release, the Mobile CMP no longer supports Global Scope. All TC Strings will be encoded with isServiceSpecific: true going forward to remain compliant with IAB TCF’s latest policy.