Display User Interfaces
Overview
The OneTrust SDK manages several different user interfaces to display to a user.
Note
The user interfaces without methods indicate they can only be navigated to from either the banner or preference center. Some views are also controlled in the OneTrust Console/Tenant.
View Name | Description | Method to Display |
---|---|---|
Banner | Notice to the user of their privacy rights. Has configurable text and buttons for Accept All, Reject All, Manage Preferences, and Close Banner. Note: Each of these buttons can be toggled On/Off in the Admin Console. | https://developer.onetrust.com/onetrust/docs/display-user-interfaces#banner |
Preference Center | An interface for the user to view additional privacy information and update their consent choices. Has configurable text and buttons for Accept All, Reject All, Save Settings, and Close Preference Center. Note: You can choose to hide each button except Save Settings - this is required for a User to update their choices. | https://developer.onetrust.com/onetrust/docs/display-user-interfaces#preference-center |
Purpose Details | The Purpose Details (or Category Details) view shows granular detail about the category and also shows the SDK List link, Vendor List link, and child categories based on configuration. | none, sub-view of Preference Center |
SDK List | An interface to show a granular list of SDKs to the user. This list may be filtered by Category to provide more transparency to the User. Note: This can hidden in Template Settings in the Admin Console. | none, sub-view of Preference Center |
IAB Vendor List | An interface, shown only for IAB2 type templates, displays a list of 3rd party ad tech vendors under management by the application. This provides a way for users to opt in/out of consent for a particular vendor. | none, sub-view of Preference Center |
Vendor Details | A child interface of Vendor List, this view shows more granular information about a vendor and its Purpose, Legitimate Interest, Special Feature, and Special Purpose settings. | none, sub-view of Preference Center |
UI Methods
As mentioned in the Configure SDK Parameters page, the SDK will only initialize and download data once one of the setupUI() methods below are called. The SDK must be initialized successfully at least once for consent to be written and stored locally.
OneTrust recommends setupUI('BANNER') be called each time upon app launch so data can be downloaded and new changes reflected, if any.
Important
oneTrustTV.Settings() must be set each time before setupUI() is called as these keys are not cached.
Banner
Renders a Banner UI after the SDK has been initialized based on the shouldShowBanner logic.
Parameter | Description |
---|---|
getElementById | Reference to the div where the UI will be be shown. |
UIType | Specify the UI type to be shown. In this case, BANNER |
Single Page Application
//method for SPAs
oneTrustTV.setupUI(document.getElementById('root'), 'BANNER', null, (status) => {
console.log('outer status -->', status);
// client logic to close the OneTrust UI
});
Multi Page Application
//method for multi page apps
oneTrustTV.setupUI(document.getElementById('root'), 'BANNER', null, () => null)
Implementations With No Banner
In an implementation where the banner may not be shown, the application may still need to know what consent is upon launch. In this case, the app should still call the setupUI('BANNER') method above. As this method evaluates the shouldShowBanner() method under the hood, no banner will be shown, data will be downloaded, and consent will be written.
Preference Center
Renders a Preference Center UI after the SDK has been initialized.
Parameter | Description |
---|---|
getElementById | Reference to the div where the UI will be be shown. |
UIType | Specify the UI type to be shown. In this case, PREFERENCE |
Single Page Application
oneTrustTV.setupUI(document.getElementById('root'), 'PREFERENCE', null, (status) => {
console.log('outer status -->', status);
// client logic to close the OneTrust UI
});
Multi Page Application
oneTrustTV.setupUI(document.getElementById('root'), 'PREFERENCE', null, () => null)
shouldShowBanner
This method determines if a Banner should be displayed to the user or not based on SDK determined logic.
oneTrustTV.shouldshowBanner(function(status) {
console.log(status);
});
Values Returned
- -1: SDK not initialized
- 1: Banner should be shown
- 0: Banner should not be shown
How shouldShowBanner
gets computed:
shouldShowBanner
gets computed:-
Is the geolocation rule configured to show a banner? This is controlled by the
showAlertNotice
property in the JSON beingtrue
.- If
showAlertNotice = false
, the method returnsfalse
and a banner should not be shown for this region. - If
showAlertNotice = true
, move to the next check.
- If
-
Was the most recent SDK Publish configured to re-consent users? This is controlled by the presence of 2 values. 1) A
LastReconsentDate
property in JSON with non-null value. 2) AOneTrustLastReconsentDate
value saved on disk- If the
LastReconsentDate
JSON is newer than theOneTrustLastReconsentDate
on disk, the method returnstrue
and a banner should be shown. - If no, move to the next check
- If the
-
Is the geolocation rule configured for automatic re-consent AND did the user's automatic re-consent timer expire? This is controlled by measuring the difference between
OneTrustLastConsentDate
saved on disk and theCurrent Date
and seeing if it is greater than or equal toOneTrustReconsentFrequencyDays
in the JSON saved on disk. The SDK considers the date itself and not the time consent was given. For example, if the re-consent period is set to 1 day in my geolocation rule and the user provides consent at 11:59pm GMT, the banner will reappear at 12:00am GMT (1 minute later, but the next day).- If yes, the method returns
true
and a banner should be shown. - If no, move to the next check
- If yes, the method returns
-
Has the user previously given consent and is that consent stored at disk?
- If yes, the method returns
false
and a banner should not be shown. - If no, the method returns
true
and a banner should be shown because this is the first time they are being asked to give consent on the app.
- If yes, the method returns
-
Has a new category been added post giving consent?
- If yes, the method returns
true
and a banner should be shown again because user needs to give consent to the new category. - If no, the method returns
false
and a banner should not be shown.
- If yes, the method returns
isBannerShown
This method determines whether or not the Banner has been shown to the user.
oneTrustTV.isBannerShown (function(status) {
console.log(status);
});
Values Returned
- -1: SDK not initialized
- 1: Banner shown
- 0: Banner not shown
Set Remote Key Mapping
If the default remote key mappings do not work properly on your device, you can manually set the key codes using this method.
oneTrustTV.setRemoteKeycodes({
"37": "left",
"38": "down",
"39": "right",
"40": "up",
"13": "ok",
"461": "back",
"1536": "back"
})
Updated 5 months ago