API (new)

Please note this is a work in progress, we will be adding more functions to support multiple regulation config.

User status

getCurrentUserStatus

Definition

Exposes the user status for the current regulation that applies.

Parameters

No parameters.

Returns

The user status containing the computed global status for Vendors and purposes:
  • A vendor's global status is enabled, if and only if:
    • the vendor is enabled directly in the vendors layer in all legal basis
    • AND all its related purposes are enabled or essential.
  • A purpose's global status is enabled in one of the two conditions:
    • the purpose is enabled for all the legal basis that it is configured for.
    • OR when the purpose is essential.
Parameter
Type
Description
vendors
object
  • Object (web) or dictionary (mobile) that maps the ID of a vendor to an object representing its status.
  • Vendors with undefined user status are included in the response with enabled: false.
  • Vendors with ONLY essential purposes are automatically set with enable: true
purposes
object
  • Object (web) or dictionary (mobile) that maps the ID of a purpose to an object representing its status.
  • Purposes with undefined user status are included in the response with enabled: false.
  • Essential purposes are automatically set with enable: true
regulation
string
  • Representation of the current regulation as a Regulation enum value, such as GDPR, CCPA, CPRA, or NONE.
  • Note that some regulations present as enum values are not available yet.
userId
string
Didomi user id.
created
string
User choices creation date.
updated
string
User choices update date.
consentString
string
TCF consent as string
additionalConsent
string
Additional consent.

Throws (Android and Flutter only)

Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.

Examples

Kotlin
Java
Swift
Objective-C
Javascript
Dart
C#
Web
val currentUserStatus = Didomi.getInstance().currentUserStatus
// Example: get consent status for vendor `google`
val vendorStatus = currentUserStatus.vendors["google"]
val isVendorEnabled = vendorStatus.enabled
CurrentUserStatus currentUserStatus = Didomi.getInstance().getCurrentUserStatus();
// Example: get consent status for vendor `google`
VendorStatus vendorStatus = currentUserStatus.vendors["google"];
bool isVendorEnabled = vendorStatus.enabled;
let currentUserStatus = Didomi.shared.getCurrentUserStatus()
// Example: get consent status for vendor `google`
let vendorStatus = currentUserStatus.vendors["google"]
let isVendorEnabled = vendorStatus.enabled
Didomi *didomi = [Didomi shared];
DDMCurrentUserStatus *currentUserStatus = [didomi getCurrentUserStatus];
// Example: get consent status for vendor `google`
DDMVendorStatus *vendorStatus = [currentUserStatus.vendors objectForKey:@"google"];
BOOL isVendorEnabled = [vendorStatus.enabled boolValue];
let currentUserStatus = await Didomi.getCurrentUserStatus();
// Example: get consent status for vendor `google`
let vendorStatus = currentUserStatus.vendors["google"]
let isVendorEnabled = vendorStatus.enabled
var currentUserStatus = await DidomiSdk.currentUserStatus;
// Example: get consent status for vendor `google`
var vendorStatus = currentUserStatus.vendors["google"]
var isVendorEnabled = vendorStatus.enabled
CurrentUserStatus currentUserStatus = Didomi.GetInstance().GetCurrentUserStatus();
// Example: get consent status for vendor `google`
var vendorStatus = currentUserStatus.Vendors["google"];
var isVendorEnabled = vendorStatus.Enabled;
Coming soon

setCurrentUserStatus

Definition

Set the user status for purposes and vendors. This function will trigger events and API calls every time it is called (and the user status changes) so make sure to push all user choices at once and not one by one.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.

Parameters

Add the desired global status for each vendor and each purpose:
  • the vendor status specified in this function will be reflected on the vendor’s layer.
    • vendor enabled : true → means the vendor is enabled in all the legal basis that this vendor uses.
    • vendor enabled : false → means the vendor is disabled in all the legal basis that this vendor uses
  • the purposes status specified in this function will be reflected on the preferences layer.
    • purpose enabled : true → means the purpose is enabled in all the legal basis in which it’s defined.
    • purpose enabled : false → means the purpose is disabled in all the legal basis in which it’s defined.

Returns

boolean
true if the user choices have changed (i.e. the user had made different choices before this function got called).

Throws (Android and Flutter only)

Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.

Examples

Kotlin
Java
Swift
Objective-C
Javascript
Dart
C#
Web
val currentUserStatus = CurrentUserStatus(
purposes = mapOf("purpose1" to CurrentUserStatus.PurposeStatus(id = "purpose1", enabled = true)),
vendors = mapOf("vendor1" to CurrentUserStatus.VendorStatus(id = "vendor1", enabled = true)),
)
val updated = Didomi.getInstance().setCurrentUserStatus(currentUserStatus)
Map<String, PurposeStatus> purposes = new HashMap<>();
purposes.put("purpose1", new PurposeStatus("purpose1", true));
Map<String, VendorStatus> vendors = new HashMap<>();
vendors.put("vendor1", new VendorStatus("vendor1", true));
CurrentUserStatus currentUserStatus = new CurrentUserStatus(purposes, vendors);
boolean updated = Didomi.getInstance().setCurrentUserStatus(currentUserStatus);
let currentUserStatus = CurrentUserStatus(
purposes: ["purpose1": PurposeStatus(id: "purpose1", enabled: true)],
vendors: ["vendor1": VendorStatus(id: "vendor1", enabled: true)]
)
let updated = Didomi.shared.setCurrentUserStatus(currentUserStatus)
DDMCurrentUserStatusPurpose *purposeStatus = [[DDMCurrentUserStatusPurpose alloc] initWithId:@"purpose1" enabled:true];
DDMCurrentUserStatusVendor *vendorStatus = [[DDMCurrentUserStatusVendor alloc] initWithId:@"vendor1" enabled:true];
NSDictionary<NSString *, DDMCurrentUserStatusPurpose *> *purposeStatuses = @{
@"purpose1": purposeStatus
};
NSDictionary<NSString *, DDMCurrentUserStatusVendor *> *vendorStatuses = @{
@"vendor1": vendorStatus
};
DDMCurrentUserStatus *currentUserStatus = [[DDMCurrentUserStatus alloc] initWithPurposes:purposeStatuses vendors:vendorStatuses];
Didomi *didomi = [Didomi shared];
bool updated = [didomi setCurrentUserStatusWithCurrentUserStatus:currentUserStatus];
const purposes: { [key: string]: PurposeStatus } = {};
purposes["purpose1"] = { id: "purpose1", enabled: true };
const vendors: { [key: string]: VendorStatus } = {};
vendors["vendor1"] = { id: "vendor1", enabled: true };
const result = await Didomi.setCurrentUserStatus({
purposes: purposes,
vendors: vendors,
user_id: '',
created: '',
updated: '',
consent_string: '',
addtl_consent: '',
didomi_dcs: '',
regulation: ''
});
var result = await DidomiSdk.setCurrentUserStatus(CurrentUserStatus(
purposes: {
"purpose1": PurposeStatus(id: "purpose1", enabled: false),
},
vendors: {
"vendor1": VendorStatus(id: "vendor1", enabled: true),
}
));
var currentUserStatus = new CurrentUserStatus
{
Purposes = new Dictionary<string, CurrentUserStatus.PurposeStatus>
{
{ "purpose1", new CurrentUserStatus.PurposeStatus { Id = "purpose1", Enabled = true } }
},
Vendors = new Dictionary<string, CurrentUserStatus.VendorStatus>
{
{ "vendor1", new CurrentUserStatus.VendorStatus { Id = "vendor1", Enabled = true } }
}
};
var updated = Didomi.GetInstance().SetCurrentUserStatus(currentUserStatus);
Coming soon

isUserStatusPartial

Definition

Determine if the user has provided a choice for all vendors selected for the regulation and linked data processing.
This function returns true if the user has not expressed a choice for all the required vendors and data processing.
Requires SDK to be initialized.

Parameters

No parameters.

Returns

boolean
  • This function returns true if the following conditions are all met
    • A regulation apply for the current user (i.e: regulation is not NONE)
    • At least one vendor is configured (if there is no vendor configured, this function always returns false as there is no status to collect)
    • We miss user status for some vendors or purposes
  • Otherwise, it will return false.
    • e.g: If regulation = none (i.e no regulation apply to the end user) → This function returns false
  • Edge cases: a new vendor is added to the notice and status is not collected yet for that vendor. In this case the function will return true until the user update their choice on the consent banner.

Throws (Android and Flutter only)

Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.

Examples

Kotlin
Java
Swift
Objective-C
Javascript
Dart
C#
Web
Didomi.getInstance().isUserStatusPartial
Didomi.getInstance().isUserStatusPartial();
Didomi.shared.isUserStatusPartial()
Didomi *didomi = [Didomi shared];
BOOL isUserStatusPartial = [didomi isUserStatusPartial];
await Didomi.isUserStatusPartial();
await DidomiSdk.isUserStatusPartial();
Didomi.GetInstance().IsUserStatusPartial();
Coming soon

shouldUserStatusBeCollected

Definition

Determine if user status (consent) should be collected for the visitor. Returns true if user status is required for the current user and one of following two conditions is met:
  • User status has never been collected for this visitor yet
  • New user status should be collected (as new vendors have been added) AND the number of days before recollecting them has exceeded
If none of these two conditions is met, the function returns false. This function is mainly present to allow you to know when to display your own notice if you have disabled our standard notice.
Requires SDK to be initialized.

Parameters

No parameter.

Returns

boolean

Throws (Android and Flutter only)

Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.

Examples

Kotlin
Java
Swift
Objective-C
Javascript
Dart
C#
Web
Didomi.getInstance().shouldUserStatusBeCollected()
Didomi.getInstance().shouldUserStatusBeCollected();
Didomi.shared.shouldUserStatusBeCollected()
Didomi *didomi = [Didomi shared];
[didomi shouldUserStatusBeCollected];
await Didomi.shouldUserStatusBeCollected()
await DidomiSdk.shouldUserStatusBeCollected()
Didomi.GetInstance().ShouldUserStatusBeCollected();
Coming soon
Last modified 1d ago