Customize User Interfaces
Overview
Note
This section is optional as most UI configurations are primarily made through the OneTrust tenant. If your app has a use case where it needs make additional configurations (e.g. font family) otherwise not available in the tenant OR if it needs to control the UI configurations locally, you can use these custom configurations.
Note
Custom UI Parameters are only supported on Native iOS (Mobile platform). This is not supported for tvOS.
As of version 6.10.0, the Native SDK supports Custom UI Parameters, which are maintained in-application through an info.plist resource.
You can find the latest info.plist in the latest demo application downloaded from OneTrust tenant. Here's how to Download latest demo app from OneTrust.
This document covers:
- Prerequisites for Customizing the UI
- Approaches to modify the plist
- Customizing the Navigation Bar
- Customizing the Banner View
- Customizing the Preference Center View
- Customizing the Purpose Details View
- Customizing the Vendor List View [for IAB TCF Customers]
- Customizing the Vendor Details View [for IAB TCF Customers]
- Customizing the SDK List View
- Customize CNIL Button
Prerequisites for customizing the UI in Native SDK views:
In order for the application to customize the UI (look and feel of SDK views), the following would be required:
- OneTrust SDK on 6.10 or above.
- The consumer application will have to conform to the
uiConfigurator
delegate inOTPublishersHeadlessSDK
. - Upon conforming to
uiConfigurator
:- The application would have to return
true
for the methodshouldUseCustomUIConfig()
. - The application can also conform to the method
customUIConfigFilePath()
and provide a custom location of theOTSDK-UIConfig.plist
.Note: Make sure that the plist is copied from the OT SDK framework to keep the format of the plist the same as the framework.
- The application would have to return
- The application can override the values (empty by default) adjacent to the keys though.
- Recommended to NOT add any rows or change the keys in the plist.
- If the application is using this approach to customize the UI, the customized items in plist will be given priority (i.e., the customized items will override the server configured values for those items).
Approaches to Modifying the OTSDK-UIConfig.plist file:
Approach 1 (Recommended)
- Set the return value as
true
for theshouldUseCustomUICOnfig()
method inUIConfigurator
protocol (refer to Sample App provided by OneTrust for example). - Locate the OTSDK-UIConfig.plist file from the
OTPublishersHeadlessSDK.framework
orOTPublishersHeadlessSDK.xcframework
.Note:
TheOTSDK-UIConfig.plist
will be present in the first level ofOTPublishersHeadlessSDK.framework
. TheOTSDK-UIConfig.plist
will be present in the each architecture folder underOTPublishersHeadlessSDK.xcframework
. You can pick it from any of the folders. - Copy this OTSDK-UIConfig.plist to the application project (refer to Sample App provided by OneTrust for example).
Note: Make sure that when we drag and drop the plist from the framework to the application project, we select Copy items if needed. This will copy the plist to the application folder hierarchy.
- Now conform to the
customUIConfigFilePath()
method which is part of theUIConfigurator
protocol (OTPublishersHeadlessSDK.shared.uiConfigurator
).Notes: While conforming to this method, provide the path to the plist in the application bundle (refer to Sample App provided by OneTrust for example).
- We can now edit this copied plist and the UI will automatically update.
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Conform to this in order to customize the UI.
OTPublishersHeadlessSDK.shared.uiConfigurator = self
}
extension AppDelegate: UIConfigurator {
func shouldUseCustomUIConfig() -> Bool {
return true
}
func customUIConfigFilePath() -> String? {
let customPath = Bundle.main.path(forResource: "OTSDK-UIConfig-iOS", ofType: "plist")
return customPath
}
}
Approach 2
- Set the return value as true for the
shouldUseCustomUICOnfig()
method inUIConfigurator
protocol (refer to Sample App provided by OneTrust, for example). - Locate the OTSDK-UIConfig.plist file from the
OTPublishersHeadlessSDK.framework
orOTPublishersHeadlessSDK.xcframework
.Note: The OTSDK-UIConfig.plist will be present in the first level of
OTPublishersHeadlessSDK.framework
. The OTSDK-UIConfig.plist will be present in the each architecture folder underOTPublishersHeadlessSDK.xcframework
. - Users can now edit the appropriate plist and the UI will automatically update.
Important Notes
- Approach 1 will provide a centralized place for the plist even if the application wants to switch between
.framework
and.xcframework
. This will avoid updating the plist file in multiple places (.framework
as well as.xcframework
). - In the future, whenever there are changes to the plist, it will be easier to figure out and resolve the changeset if Approach 1 chosen.
- By default all the values in the OTSDK-UIConfig.plist in the OT SDK framework will be empty.
- In order to customize an element, we will need to enter a valid value for the associated key we want to customize.
- When a custom
fontName
is provided, at least one of thefontSize
orfontTextStyle
should also be provided in order for it to reflect. - In order for dynamic font size to be supported, the application will have to provide a valid value for
fontTextStyle
if customizing the fonts. - Button color for Mobile templates can updated in the SDK using UX Params. For more information, see JSON Structure.
The following are the different fontTextStyle
options supported:
largeTitle
title1
title2
title3
headline
subheadline
body
callout
footnote
caption1
caption2
UI Customization for Page Header (Navigation Bar) in all SDK Views:
The consumer application has to edit the OTSDK-UIConfig.plist file located in the SDK bundle in order to customize the UI. All the page header related customization would be present under the pageHeader
dictionary. This is a common theme that will be applied to all the OT SDK views' navigation bars.
The following are the customizations available:
- backgroundColor (String) - A hex string representing the background color of the page header/navigation bar.
- (ex: #FFFFFF)
- tintColor (String) - A hex string representing the tint color of the page header/navigation bar.
- (ex: #FFFFFF)
- fontName (String) - The name of the custom font.
- (ex: HelveticaNeue).
- fontSize (Int) - The size of the font.
- (ex: 17)
- fontTextStyle (String) - The preferred text style of the font.
- (ex: Headline, callout, sub headline etc.)
- textAlignment (String) - The alignment of the text.
- (Options - Center, Left, Right)
- textColor (String) - A hex string representing the color of the text.
- (ex: #000000)
Banner View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the banner view related customization would be present under the bannerTheme
dictionary.
The following color options are available for the Banner View:
- backgroundColor (String) - A hex string representing the background color of the banner view
- (ex: #FFFFFF)
The following are the customizations available for the Banner View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Summary | title description | Banner Title; IAB Title Banner Description; IAB Descriptions | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Buttons | closeButtonColor acceptAll rejectAll showPreferences | Close button Accept All button Reject All button Show Preferences button | backgroundColor (String) fontName (String) fontSize (Int) fontTextStyle (String) textColor (String) borderColor (String) borderRadius (Int) borderWidth (Int) |
Links | policyLink vendorList | More Information link Vendor List link | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Preference Center View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the preference center related customization would be present under the preferenceCenterTheme
dictionary in the plist.
The following color options are available for the Preference Center View:
- backgroundColor (String) - A hex string representing the background color of the Preference Center.
- (ex: #FFFFFF)
- lineBreakColor (String) - A hex string representing the separator lines color
- (ex: #FFFFFF)
- toggleColor (String) - A hex string representing the switch color when toggled ON
- (ex: #FFFFFF)
The following UI elements are the customizations available for the Preference Center View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Summary | title description | Preference Center Title Preference Center Description | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Purpose Title | purposeTitle | Purposes/Categories Titles | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Purposes Always Active Status | purposesAlwaysActiveStatus | Always Active Status text | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Buttons | acceptAll rejectAll confirmMyChoice | Accept All button Reject All button Show Preferences button | backgroundColor (String) fontName (String) fontSize (Int) fontTextStyle (String) textColor (String) borderColor (String) borderRadius (Int) borderWidth (Int) |
Links | policyLink vendorList | More Information link Vendor List link | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Show Logo on PC | showLogoOnPC | PC | false |
Purposes Details View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the purpose details view related customization would be present under the purposeDetailsTheme
dictionary in the plist.
The following color options are customizations available for the Purposes Details View:
- backgroundColor (String) - A hex string representing the background color of the purposes details view
- (ex: #FFFFFF)
- lineBreakColor (String) - A hex string representing the separator lines color
- (ex: #FFFFFF)
- toggleColor (String) - A hex string representing the switch color when toggled On
- (ex: #FFFFFF)
The following UI Elements are the customizations available for the Purposes Details View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Group Summary | title description | Purpose Details Title Purpose Details Description | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Consent Title | consentTitle | Consent Title | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Legitimate Interest | legitInterestTitle | Legit Interest Title | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Purposes Always Active Status | alwaysActiveStatus | Always Active Status text | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Links | sdkList vendorList fullLegalText | SDK Lists link Vendor Lists link Full Legal Text link | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Vendor List View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the vendor list view related customization would be present under the vendorListTheme
dictionary in the plist.
The following color options are customizations available for the Vendor List View:
- backgroundColor (String) - A hex string representing the background color of the vendor list
- (ex: #FFFFFF)
- lineBreakColor (String) - A hex string representing the separator lines color
- (ex: #FFFFFF)
- toggleColor (String) - A hex string representing the switch color when toggled ON
- (ex: #FFFFFF)
- filterOnColor (String) - A hex string representing the filter icon color when filter is applied
- (ex: #FFFFFF)
- filterOffColor (String) - A hex string representing the switch color when no filter is applied
- (ex: #FFFFFF)
- filterSelectionColor (String) - A hex string representing the tint color of the check mark in the vendor filter list
- (ex: #FFFFFF)
The following UI Elements are the customizations available for the Vendor List View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Vendor List Navigation | filterNavText | Vendor Filter Navigation Bar text(s) | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Vendor Item | title | Vendor Item | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Filter Item | filterItemTitle | Filter Item | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Buttons | confirmMyChoices applyFilter | Confirm My Choices button Apply Filter button | backgroundColor (String) fontName (String) fontSize (Int) fontTextStyle (String) textColor (String) borderColor (String) borderRadius (Int) borderWidth (Int) |
Search Bar | searchBar | Vendor List Search Bar | textColor(String) placeholderTextColor(String) backgroundColor(String) iconColor(String) borderColor(String) borderWidth(Int) borderRadius(Int) |
Vendor Details View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the vendor details view related customization would be present under the vendorDetailsTheme
dictionary in the plist.
The following color options are customizations available for the Vendor Details View:
- backgroundColor (String) - A hex string representing the background color of the vendor details view
- (ex: #FFFFFF)
- toggleColor (String) - A hex string representing the switch color when toggled ON
- (ex: #FFFFFF)
The following UI Elements are the customizations available for the Vendor Details View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Title | title | Vendor Details Title | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Details Summary | title description | Vendor Details Description Title Vendor Details Description | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Consent Title | consentTitle | Consent Title | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Legitimate Interest | legitInterestTitle | Legit Interest Title | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Links | privacyNotice | Privacy Notice link | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
SDK List View
The consumer application has to edit the OTSDK-UIConfig.plist file in order to customize the UI. All the SDK list view related customization would be present under the sdkListTheme
dictionary in the plist.
The following color options are customizations available for the SDK List View:
- backgroundColor (String) - A hex string representing the background color of the SDK list
- (ex: #FFFFFF)
- lineBreakColor (String) - A hex string representing the separator lines color
- (ex: #FFFFFF)
- filterOnColor (String) - A hex string representing the filter icon color when filter is applied
- (ex: #FFFFFF)
- filterOffColor (String) - A hex string representing the switch color when no filter is applied
- (ex: #FFFFFF)
The following UI Elements are the customizations available for the SDK List View:
UI Element | Key Name | Applied To | Default Value |
---|---|---|---|
Summary | title description | SDK Item Title SDK Item Description | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Check Mark Filter Selection | filterSeletionColor | Check Mark tint color | selectionColor (String) |
SDK Filter List Navigation Bar | filterNavText | SDK Filter List Navigation Bar text(s) | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
SDK Filter Item | sdkItem | Filter Item | fontName (String) fontSize (Int) fontTextStyle (String) textAlignment (String) textColor (String) |
Buttons | applyFilter | Apply Filter button | backgroundColor (String) fontName (String) fontSize (Int) fontTextStyle (String) textColor (String) borderColor (String) borderRadius (Int) borderWidth (Int) |
Search Bar | searchBar | SDK List Search Bar | textColor(String) placeholderTextColor(String) backgroundColor(String) iconColor(String) borderColor(String) borderWidth(Int) borderRadius(Int) |
Display CNIL as Button
With OneTrust 6.22.0, mobile app customers can now customize the Continue Without Accepting link as a button to promote a consistent experience when presented with a close option. For more information on the app-side configuration of mobile templates to display as text or link, see CNIL Mobile App Requirements on the myOneTrust Knowledge Base.
UIConfigurator
- Return True
UIConfigurator
- Return True- Open the
AppDelegate.swift
file. - Locate the
shouldUseCustomUIConfig() -> Bool
function. - Update the value as
return true
. It will be set toreturn false
by default.
extension AppDelegate: UIConfigurator {
func shouldUseCustomUIConfig() -> Bool {
return true
}
Customize closeButton
closeButton
- Open the
OTSDK-UIConfig-iOS.plist
file. - Locate
Root > bannerTheme > buttons > closeButton
. - The parameters for
closeButton
will be blank by default. Provide your customizations for the Continue Without Accepting button.
Key Name | Type |
---|---|
backgroundColor | String |
fontName | String |
fontSize | Number |
fontTextStyle | String |
textColor | String |
borderColor | String |
borderWidth | Number |
borderRadius | Number |
Using Custom Fonts
The Native SDK can support a Font Name override to support custom fonts.
- Add custom fonts to Xcode: Apple documentation
- Reference the fonts in the SDK plist. Ensure you specify a font size in the plist for the custom font to take effect.
Updated about 2 months ago