Updating Consent¶
As your App evolves throughout time, so will the frameworks running on it. Therefore, you will need to update consent by reshowing the CMP whenever there are changes or updates to your terms of service.
For this, we provide initialLayer
, which you can use to know if you need to show the CMP or just apply consent. See:
usercentrics.initialize { initialValues in
switch initialView.initialLayer {
case .firstLayer:
self.presentCMP()
case .none:
self.updateServices()
}
} onFailure: { error in
// Handle non-localized error
}
For this, we provide initialLayer
, which you can use to know if you need to show the CMP or just apply consent. See:
usercentrics.initialize(
callback = { initialValues ->
when (initialValues.initialLayer) {
InitialView.FIRST_LAYER -> presentCMP()
InitialView.NONE -> updateServices()
}
}, onFailure = { error ->
// Handle non-localized error
}
)
For this, we provide the showCMP
flag, which you can use to know if you need to show the CMP or just apply consent. See:
Usercentrics.Instance.Initialize((showCMP) =>
{
if (showCMP)
{
PresentCMP();
}
else
{
UpdateServices();
}
},
(errorMessage) =>
{
// Handle non-localized error
});
Collecting Consent for the First Time
The first time you initialize the SDK, initialLayer
will also return firstLayer
, so the above example will handle all cases of presenting the CMP when consent needs to be collected or updated.