OneTrust UI Helpers
OneTrust SDK Public Methods for Showing the User Interfaces
Existing
Setting up OneTrust SDK UI (call before startSDK
)
startSDK
)This API sets up the OT SDK UI and checks if the UI needs to be shown and presents the UI based on this check.
Call this method on application's main view controller.
Note: This API uses the shouldShowBanner logic to determine if the OT SDK UI should be shown to the user.
Parameters:
viewController
: The View Controller of the application on which the OT SDK UI will be presented.UIType
: Represents the various types of OT SDK UI that can be presented using this API. Whatever type is passed here, will be displayed if the conditions are satisfied. If the app does not want to show OT SDK UI, then skip this parameter or pass in.none
.
Display Banner UI
This API displays the OneTrust SDK Banner UI. It should be called only after the setupUI() method has been executed at least once during the current application session and the OneTrust SDK data has been successfully downloaded. This method does not consider the value of shouldShowBanner.
OTPublishersHeadlessSDK.shared.showBannerUI()
Display Preference Center UI
This API displays the OneTrust SDK Preference Center UI. It should be called only after the setupUI() method has been executed at least once during the current application session and the OneTrust SDK data has been successfully downloaded. This method does not consider the value of shouldShowBanner.
OTPublishersHeadlessSDK.shared.showPreferenceCenterUI()
Adding Event listeners for UI events from OneTrust
This API adds an event listener to OT SDK UI.
Parameter
eventListener
: Pass any object that conforms toOTEventListener
, where you want to listen to events with regards to OT SDK UI.
Note:The object being passed should conform to OTEventListener. Otherwise this listener will not be set.
OTPublishersHeadlessSDK.shared.addEventListener(_:)
Dismiss OneTrust UI
This API dismisses the OT SDK UI if the UI is already present in the view hierarchy.
OTPublishersHeadlessSDK.shared.dismissUI()
Checking if OneTrust UI is currently displayed
Returns a boolean indicating if OT SDK is currently displaying its view in the current view hierarchy.
OTPublishersHeadlessSDK.shared.sdkViewsCurrentlyPresented() -> Bool
Check if OneTrust UI was ever presented
Determines if OT SDK Banner/Preference center was presented to user at least once. This method will support only if SDK UI methods are used.
Returns:
- -1: if SDK not initialized yet.
- 0: if Banner/Preference Center was not shown yet (implied consent).
- 1: if Banner/Preference Center shown.
- 2: if consent taken using profile syncing
Updated 3 days ago