Multi Profile Consent

Android

Multi Profile Support

Support for multi profiles have been added to OT SDK based on the profile ID/DSID. As part of this feature, all the information associated with a user will be stored on a profile level basis locally on the device. As a result, whenever a profileID/DSID is set by an application, that particular profile will be loaded.

In order to use Multi Profile consent, you must first enable it in your templates section. Cookie Consent > Templates > Select a Template > Enable the mobile app template (under details) > Navigate to the mobile app platform > Banner > Multi Profile Consent.

📘

Number of Profiles Supported

The SDK only supports up to 6 profiles today.

Default Profile

There will always be a default profile configured by the OneTrust SDK. Whenever a Profile ID/DSID is not set by the application, we will load this default profile. At any point, there will be only one such default profile maintained by OT SDK.

Retrieve Current Profile ID

This method allows you to retrieve the identifier of the current profile.

new OTPublishersHeadlessSDK().getCurrentActiveProfile(); 
	//Returns a string 

Renaming or Overriding Profiles/Data Subject Identifier

By default, the OneTrust SDK logs a user's consent anonymously under a random GUID. The ID and consent is stored locally on the device as well as in the OneTrust database (if the consent logging toggle is enabled in your geolocation rules).

The following method can be used to rename a profile from one DSID/Profile ID to another.

OTRenameProfileParams.OTRenameProfileParamsBuilder otRenameParamsBuilder = OTRenameProfileParams.OTRenameProfileParamsBuilder.newInstance();
     otRenameParamsBuilder = otRenameParamsBuilder.setOldProfileID("");
     otRenameParamsBuilder = otRenameParamsBuilder.setNewProfileID("");
     otRenameParamsBuilder = otRenameParamsBuilder.setIdentifierType(""); //optional, only required for Unified Profile
     OTRenameProfileParams otRenameParams = otRenameParamsBuilder.build();
     otfragment.renameProfile(otRenameParams, new OTCallback() {
          @Override
          public void onSuccess(@NonNull OTResponse otSuccessResponse) {
              Log.v("Rename Profile", "Profile rename success);
          }
          @Override
          public void onFailure(@NonNull OTResponse otErrorResponse) {
              Log.e("Rename Profile", "Profile rename failed");
          }
});
  • Ensure that the new DSID is unique and does not already exist.
  • Ensure that startSDK() has been called at least once.

Please note: This method will only rename the profile ID stored locally on the device. The ID stored in the OneTrust Consent database will not update until the user interacts with the CMP again. If you want to have the ID stored in the consent database to be updated right away (without interaction from the user), the recommendation is to to call saveConsent() after renameProfile. This will commit the user's consent choices again and create a new receipt.

otPublishersHeadlessSDK.saveConsent(OTConsentInteractionType.PC_CONFIRM)

Switching Profiles

Profile switching will happen in the following scenarios:

  • Whenever startSDK() is called, we will be checking for identifier that will be passed as part of sdkParams object (link to section here:https://developer.onetrust.com/onetrust/docs/initialize-the-sdk-android#cross-device-consent). If this identifier is empty, we will be switching to/loading the default profile maintained by OT SDK.
  • Whenever switchProfile() is called, we will be checking to see if the data is available for switching to the new profile. If it is available, we will switch to the new profile.
  • If an empty identifier is passed, we will be loading the default profile maintained by OT SDK.
    • For data availability, we check if culture data, common data and domain data are available locally for all profiles.

Note: Switching profiles when cross device sync is enabled is not supported yet.

new OTPublishersHeadlessSDK(context).switchUserProfile("profileID", new OTCallback(){ 
@Override 
public void onSuccess(@NonNull OTResponse otResponse){ 
  
} 

@Override 
public void onFailure(@NonNull OTResponse otResponse){ 

} 
}); 

Deleting Profile

The following method can be used to delete a profile. If the profile being deleted is currently active, we switch the active profile to default profile and then delete it.

new OTPublishersHeadlessSDK(context).deleteProfile("profileID", new OTCallback(){ 
@Override 
public  void onSuccess(@NonNull OTResponse otResponse){ 

} 

@Override 
public void onFailure(@NonNull OTResponse otResponse){ 
  
} 
}); 

Calling clearOTSDKData() will delete all SDK data, including all profiles.

Note: Ensure that startSDK() is called at least once before calling the deleteProfile()