Universal Consent Purposes

📘

Important

Universal Consent Purposes for Mobile is part of the UCPM offering and you must have a UCPM license to use this module.

Overview

Universal Consent can be used to serve a different use case compared to the regular Mobile App Consent banner and this can also be configured within the Mobile SDK. Rather than collecting user consent to help manage SDKs and other technologies on the app, Universal Consent helps collect consent for purposes like promotional emails, newsletters, SMS messaging, etc. that typically require an integration with a third party system like Salesforce and Marketo. After a Universal Consent transaction is collected, integration workflows can be triggered within the OneTrust tool.

Universal Consent requires a user identifier to work properly. By default, consent will stored against the device, rather than a specific user identifier. In order to create a profile for the user in OneTrust and to benefit from features such as creating integration worfklows, you can tie the consent to a specific user identifier by set a data subject and keep their consent in sync with other collection methods, utilizing the Profile Sync Params guidance.

📘

Note

Before proceeding, make sure that Universal Consent purposes has been configured inside of the OneTrust Admin Portal. View instructions here

To create integration workflows please use the following article

Initialize SDK

The OneTrust SDK retrieves an object that contains all the data needed to present the Universal Consent Preference Centre and collect consent for the specified purposes. The data returned is determined by the configurations made in the OneTrust Admin console. For more details on how to initialize the OneTrust SDK, please refer to the linked iOS and android documentation.

Display Universal Consent Preference Center

To load the Universal Consent preference center over the current screen, simply call:

OTPublishersHeadlessSDK.shared.showConsentPurposesUI(self)

Query for Universal Consent Values

The SDK exposes methods to retrieve the current state of the users' consent.

StatusExplanation
1Consent is given (An end user interacts with the SDK and gives consent.)
0Consent is not given (An end user interacts and does not give consent.)
-1Consent has not been collected (The SDK is not yet initialized for the end user.)

You can query the consent status for Universal Consent Purposes, Topic and Custom Preferences.

Get Purpose Consent

To query for the top-level purpose's consent:

OTPublishersHeadlessSDK.shared.getUCPurposeConsent(purposeID: "purposeId")
ArgumentTypeDescription
purposeIdStringThe GUID of the purpose to retrieve.

Get Custom Preferences Consent

To query for a custom preference nested under a purpose:

OTPublishersHeadlessSDK.shared.getUCPurposeConsent(customPreferenceOptionID: "custPrefOptionID", customPreferenceID: "custPrefID", purposeID: "purposeID")
ArgumentTypeDescription
customPreferenceOptionIdStringThe GUID of the custom preference option
customPreferenceIdStringThe GUID of the custom preference group
purposeIdStringThe GUID of the purpose under which the custom preference is nested.

Broadcast Listener - Universal Purposes

Universal Consent Purposes broadcast steps are same as the normal category broadcasts. The app will be listening to each of the purpose Ids (intent filter will be purposeId GUID).

Event Name:

Observer Callback

    @objc func actionConsent_UCPurpose(_ notification:Notification) {
        let consentDetails = notification.object as? [String:Any]
        NSLog("UCPurpose consent change dictionary = \(consentDetails ?? [:])")
    }

Register Event Broadcast

NotificationCenter.default.addObserver(
                    self,
                    selector: #selector(actionConsent_UCPurpose(_:)),
                    name: NSNotification.Name(rawValue: eventId),
                    object: nil)

This will give a JSON string which contains Topics, Custom Preferences and ID statuses with respect to the Purpose app is listening for in the following format:

{
	status: 0, 
	custom_preferences”: {
		"cpId": {
			“cpOptionID1”: 0, 
			”cpOptionID1”: 0
		}
	}, 
	”topics”: {
		"topicOpId1": 0,
		"topicOpId2": 1
	}
}

Destroying the observer

NotificationCenter.default.removeObserver(NSNotification.Name(rawValue: "OTConsentUpdated"))

The broadcast will be triggered only for those purpose IDs which have a change in its saved consent values. If any of the Topic and Custom Preference options consent of a purpose ID changes, then SDK will trigger broadcasts for that purposeId.

Programatically Set Universal Consent Values

The SDK exposes methods to programatically set the users' consent values. A common use case is when a sign-up form has a checkbox at the bottom to allow the user to opt into emails. In this case, the application would set the value of the associated purpose, and the user could change his or her decision later in the preference center.

📘

Note

After making consent updates, the application must call the  saveConsent(type: .ucPreferenceCenterConfirm) function to commit the changes.

Update Purpose Consent

To update the top-level purpose's consent:

OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(purposeId: "purposeID", withConsent: true)
ArgumentTypeDescription
purposeIdStringThe GUID of the purpose to update
consentBooleanWhether or not consent has been granted for the specified item

Update Custom Preference Consent

To update a custom preference nested under a purpose:

OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(cpOptionId: "customPreferenceOptionId", cpId: "customPreferenceId", purposeId: "purposeId", withConsent: true)
ArgumentTypeDescription
customPreferenceOptionIDStringThe GUID of the custom preference option
customPreferenceIdStringThe GUID of the custom preference group
purposeIdStringThe GUID of the purpose under which the custom preference is nested.
consentBooleanWhether or not consent has been granted for the specified item

Save Consent

After making updates to the consent values, the application must call the following method to commit the changes:

OTPublishersHeadlessSDK.shared.updateUCPurposeConsent(purposeId: "purposeId", withConsent: true)
OTPublishersHeadlessSDK.shared.saveConsent(type: .ucPreferenceCenterConfirm)