Skip to content

API

Core

Initialize

Called to configure and initialize Usercentrics after app launch

Usercentrics.Instance.Initialize(
    (usercentricsReadyStatus) =>
    {
        // Success: Returns UsercentricsReadyStatus object
    },
    (errorMessage) =>
    {
        // Failure: Returns non-localized error
    }
);

Show Usercentrics Banner's First Layer

When called, it will display the Banner on First Layer with Admin Interface configuration.

Usercentrics.Instance.ShowFirstLayer(<UsercentricsLayout> /* Full, Sheet, PopupBottom, PopupCenter */, (usercentricsConsentUserResponse) =>
{
    // Handle userResponse
});

Show Usercentrics Banner's Second Layer

When called, it will display the Banner on Second Layer with Admin Interface configuration.

Usercentrics.Instance.ShowSecondLayer(<showCloseButton> /* true/false */, (usercentricsConsentUserResponse) =>
{
    // Handle userResponse
});

Restore user session

Restore Consents given by a user using its Controller ID.

Usercentrics.Instance.RestoreUserSession(<controllerId>, (usercentricsReadyStatus => {}), (errorString => {});

Reset

Resets Usercentrics SDK, deleting all local data and forcing to be initialized again.

Usercentrics.Instance.Reset();

Helpers

Platform is supported

Get if current selected platform is supported by Usercentrics.

Usercentrics.Instance.IsPlatformSupported();

Get Controller ID

Usercentrics.Instance.GetControllerID();

TCF 2.0

Get TCF Data

Retrieve all data related to TCF 2.0, as well as the consent string. (TCString) Your CMP configuration needs to be set for TCF, otherwise this object will be empty.

Usercentrics.Instance.GetTCFData((tcfData) =>
{
    var purposes = tcfData.purposes;
    var specialPurposes = tcfData.specialPurposes;
    var features = tcfData.features;
    var specialFeatures = tcfData.specialFeatures;
    var stacks = tcfData.stacks;
    var vendors = tcfData.vendors;

    // TCString
    var tcString = tcfData.tcString;
});

CCPA

Get CCPA (USP) Data

Retrieve all data related to CCPA, as well as the consent string. (USPString) Your CMP configuration needs to be set for CCPA, otherwise this object will be empty.

Usercentrics.Instance.GetUSPData();

Event

Subscribe to any consent updated event that happens within Usercentrics SDK This API is meant for third-parties, that need to pull consent from the Usercentrics SDK.

Usercentrics.Instance.SubscribeOnConsentUpdated((usercentricsUpdatedConsentEvent =>
{
    var consents = usercentricsUpdatedConsentEvent.consents;
    var controllerId = usercentricsUpdatedConsentEvent.controllerId;
    var tcString = usercentricsUpdatedConsentEvent.tcString;
    var uspString = usercentricsUpdatedConsentEvent.uspString;
}));

Dispose Content Listener

Dispose any subscription to this API.

Usercentrics.Instance.DisposeOnConsentUpdatedSubscription();