Documentation Index

Fetch the complete documentation index at: https://usercentrics.document360.io/llms.txt

Use this file to discover all available pages before exploring further.

Display the banner

Prev Next

Usercentrics UI is a native UI component designed to own all the complexity of compliance, while also allowing different levels of customization.

This component consists of two layers:

Banner first layer

The first layer is designed to be friendly to end-users, compact and highly customizable. This layer can be presented in three different ways:

Recommendation

Use the first layer when collecting consent for the first time or when prompting updates to the consent services. Remember that user's will be able to navigate from the first layer to the second layer.

To present the first layer, simply create an instance of UsercentricsBanner, and call showFirstLayer(). Once the user provides their consent choices, a userResponse object will be returned.

let banner = UsercentricsBanner()
banner.showFirstLayer() { userResponse in
    // Handle userResponse
}

Passing a specific HostView

You may also pass a specific HostView as a parameter of showSecondLayer(hostView: <UIViewController>). If not provided, the SDK will resolve the HostView from the presented view controller of the first window.

Support for Swift UI

Support for Swift UI is available starting v2.7.6. On our iOS sample app you can find an example of how to integrate with Swift UI.

val banner = UsercentricsBanner(<Context>)
banner.showFirstLayer() { userResponse ->
    // Handle userResponse
}

Use a valid Context

We are using the Dialog Android API for the Banner implementation. It is recommended to use a Context that is an Activity or derived/wrapper from it. Note that the Activity has to be alive for the dialog to be displayed.

final userResponse = await Usercentrics.showFirstLayer();
// Handle userResponse
const userResponse = await Usercentrics.showFirstLayer();
// Handle userResponse
Usercentrics.Instance.ShowFirstLayer(<UsercentricsLayout>, (userResponse) => {
    // Handle userResponse
});

Banner second layer

The second layer is designed to own all the complexity of compliance, declare all legally required information and allow for granular choices.

Recommendation

Use the second layer to allow users to review their choices from your apps settings.

To present the second layer, similarly create an instance of UsercentricsBanner, and call showSecondLayer(). The same userResponse object will be returned here as well.

let banner = UsercentricsBanner()
banner.showSecondLayer() { userResponse in
    // Handle userResponse
}

Passing a specific HostView

You may also pass a specific HostView as a parameter of showSecondLayer(hostView: <UIViewController>). If not provided, the SDK will resolve the HostView from the presented view controller of the first window.

Support for Swift UI

Support for Swift UI is available starting v2.7.6. On our iOS Sample App you can find an example of how to integrate with SwiftUI.

val banner = UsercentricsBanner(<Context>)
banner.showSecondLayer() { userResponse ->
    // Handle userResponse
}

Use a valid Context

We are using the Dialog Android API for the Banner implementation. It is recommended to use a Context that is an Activity or derived/wrapper from it. Note that the Activity has to be alive for the dialog to be displayed.

final userResponse = await Usercentrics.showSecondLayer();
// Handle userResponse
const userResponse = await Usercentrics.showSecondLayer();
// Handle userResponse
Usercentrics.Instance.ShowSecondLayer(<showCloseButton>, (userResponse) => {
    // Handle userResponse
});