API

This section is a comprehensive reference of the methods and events exposed by the iOS SDK that you can leverage in your application.

Always use Didomi.shared to get a reference to the Didomi SDK. Also make sure to always call the SDK after it is fully initialized (see onReady).

addEventListener

Add an event listener to catch events triggered by the SDK. See the dedicated section for more details

getDisabledPurposes

Get the list of purposes that have been disabled by the user.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Purpose]

An array of type Purpose containing the purposes disabled by the user.

Example

Swift
Swift
Didomi.shared.getDisabledPurposes()

getDisabledPurposeIds

Get the list of purpose IDs that have been disabled by the user.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of purposes disabled by the user.

Example

Swift
Objective-C
Swift
Didomi.shared.getDisabledPurposeIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *disabledPurposeIds = [didomi getDisabledPurposeIds];

getDisabledVendors

Get the list of vendors that have been disabled by the user.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Vendor]

An array of type Vendor containing the vendors disabled by the user.

Example

Swift
Swift
Didomi.shared.getDisabledVendors()

getDisabledVendorIds

Get the list of vendor IDs that have been disabled by the user.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of vendors disabled by the user.

Example

Swift
Objective-C
Swift
Didomi.shared.getDisabledVendorIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *disabledVendorIds = [didomi getDisabledVendorIds];

getEnabledPurposes

Get the list of purposes that have been enabled by the user.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Purpose]

An array of type Purpose containing the purposes enabled by the user.

Example

Swift
Swift
Didomi.shared.getEnabledPurposes()

getEnabledPurposeIds

Get the list of purpose IDs that have been enabled by the user.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of purposes enabled by the user.

Example

Swift
Objective-C
Swift
Didomi.shared.getEnabledPurposeIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *enabledPurposeIds = [didomi getEnabledPurposeIds];

getEnabledVendors

Get the list of vendors that have been enabled by the user.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Vendor]

An array of type Vendor containing the vendors enabled by the user.

Example

Swift
Swift
Didomi.shared.getEnabledVendors()

getEnabledVendorIds

Get the list of vendor IDs that have been enabled by the user.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of vendors enabled by the user.

Example

Swift
Objective-C
Swift
Didomi.shared.getEnabledVendorIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *enabledVendorIds = [didomi getEnabledVendorIds];

getJavaScriptForWebView

Get JavaScript to embed into a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.

Inject the returned tag into a WebView with evaluateJavaScript.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

String

NSString *

JavaScript code to embed in a WebView

Example

Swift
Objective-C
Swift
Didomi.shared.getJavaScriptForWebView()
Objective-C
Didomi *didomi = [Didomi shared];
NSString *javaScriptForWebView = [didomi getJavaScriptForWebView];

getQueryStringForWebView

Get a query string parameter to append to the URL of a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.

Read our article on sharing consent with WebViews for more information.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

String

Query string parameter with the format didomiConfig.user.externalConsent.value=.... It can be appended to your URL after a ? or a & if your URL already contains a query string.

Example

Swift
Objective-C
Swift
Didomi.shared.getQueryStringForWebView()
Objective-C
Didomi *didomi = [Didomi shared];
NSString *queryStringForWebView = [didomi getQueryStringForWebView];

getPurpose

Get a purpose based on its ID.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

purposeId

String

ID of the purpose we want to get.

Returns

Type

Description

Purpose

A Purpose with ID purposeId found in the array of required purposes.

Example

Swift
Swift
Didomi.shared.getPurpose(purposeId: "purpose-id")

getRequiredPurposes

Get the list of purpose that are required (automatically determined from the list of required vendors).

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Purpose]

An array of type Purpose containing the required purposes.

Example

Swift
Swift
Didomi.shared.getRequiredPurposes()

getRequiredPurposeIds

Get the list of purpose IDs that are required (automatically determined from the list of required vendors).

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of required purposes.

Example

Swift
Objective-C
Swift
Didomi.shared.getRequiredPurposeIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *requiredPurposeIds = [didomi getRequiredPurposeIds];

getRequiredVendors

Get the list of vendors that are required (determined from the configuration).

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type

Description

[Vendor]

An array of type Vendor containing the required vendors.

Example

Swift
Swift
Didomi.shared.getRequiredVendors()

getRequiredVendorIds

Get the list of vendor IDs that are required (determined from the configuration).

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Type (Swift)

Type (Objective-C)

Description

Set<String>

NSSet<NSString *> *

A set of type String containing the IDs of required vendors.

Example

Swift
Objective-C
Swift
Didomi.shared.getRequiredVendorIds()
Objective-C
Didomi *didomi = [Didomi shared];
NSSet<NSString *> *requiredVendorIds = [didomi getRequiredVendorIds];

getText

Method used to get a dictionary/map based on the key being passed. These keys and texts are extracted from the notice content, preferences content and the texts property specified in the didomi_config.json file as described here https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-theme#translatable-texts-for-custom-notices.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

key

String

key associated to the dictionary that we want to get.

Returns

Type

Description

Dictionary/map

Dictionary/map containing the translations for an specific key in different languages, with the form { "en:" "text in English", "fr": "texte en Français" }

Example

Swift
Objective-C
Swift
Didomi.shared.getText("key")
Objective-C
Didomi *didomi = [Didomi shared];
NSString *translatedText = [didomi getTextWithKey:@"key"];

getTranslatedText

Method used to get a translated text based on the key being passed.

The language and the source of this translated text will depend on the availability of the translation for the specific key.

The language being used will be either the selected language of the SDK (based on device Locale and other parameters) or the language specified by app developers as the default language being used by the SDK. The source can be either the didomi_config.json file, which can be either local or remote, or a file that is bundled within the SDK.

These are the attempts performed by the SDK to try to find a translation for the specific key:

  • Get translated value in user locale (selected language) from didomi_config.json (either local or remote).

  • Get translated value in default locale (from the config) from didomi_config.json (either local or remote).

  • Get translated value in user locale (selected language) from the Didomi-provided translations (bundled within the Didomi SDK).

  • Get translated value in default locale (from the config) from the Didomi-provided translations (bundled within the Didomi SDK).

If no translation can be found after these 4 attempts, the key will be returned.

App developers can provide these translated texts through the didomi_config.json file (locally or remotely) in 3 different ways:

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

key

String

key associated to the text that we want to get translated.

Returns

Translated text.

Example

Swift
Objective-C
Swift
Didomi.shared.getTranslatedText("key")
Objective-C
Didomi *didomi = [Didomi shared];
NSString *translatedText = [didomi getTranslatedTextWithKey:@"key"];

getUserConsentStatusForPurpose

Get the user consent status for a given purpose. You must also check that the user has given consent to a vendor specifically before being able to load a vendor.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

purposeId

String

The ID of the purpose to check the user consent for.

Returns

A ConsentStatus object that indicates if the user has given consent or not to the specific purpose.

ConsentStatus.enable is returned if the user has given consent to the purpose. ConsentStatus.disable is returned if the user has denied consent.

ConsentStatus.unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable (ie "no consent given") but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for the consent information to be collected.

If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable.

Example

Swift
Objective-C
Swift
Didomi.shared.getUserConsentStatusForPurpose("purpose-id")
Objective-C
Didomi *didomi = [Didomi shared];
ConsentStatus consentStatusForPurpose = [didomi getUserConsentStatusForPurposeWithPurposeId:@"purpose-id"];

getUserConsentStatusForVendor

Get the user consent status for a given vendor. You must also check that the user has given consent to some or all of the purposes required by a vendor before loading the vendor. The function getUserConsentStatusForVendorAndRequiredPurposes does all the required checks for you so it might be a better choice.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

vendorId

String

The ID of the vendor to check the user consent for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.

Returns

A ConsentStatus object that indicates if the user has given consent or not to the specific vendor.

ConsentStatus.enable is returned if the user has given consent. ConsentStatus.disable is returned if the user has denied consent.

ConsentStatus.unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable (ie "no consent given") but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for the consent information to be collected.

If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable.

In Objective-C, the return value is an Int and not an Enum. It can take one of the following values:

  • ConsentStatusEnable

  • ConsentStatusDisable

  • ConsentStatusUnknown

Example

Swift
Objective-C
Swift
// IAB vendors
Didomi.shared.getUserConsentStatusForVendor("1")
// Didomi vendors
Didomi.shared.getUserConsentStatusForVendor("google")
// Custom vendors
Didomi.shared.getUserConsentStatusForVendor("c:custom-vendor-id")
Objective-C
Didomi *didomi = [Didomi shared];
// IAB vendors
ConsentStatus iabConsentStatusForVendor = [didomi getUserConsentStatusForVendorWithVendorId:@"1"];
// Didomi vendors
ConsentStatus didomiConsentStatusForVendor = [didomi getUserConsentStatusForVendorWithVendorId:@"google"];
// Custom vendors
ConsentStatus customConsentStatusForVendor = [didomi getUserConsentStatusForVendorWithVendorId:@"c:custom-vendor-id"];

getUserConsentStatusForVendorAndRequiredPurposes

Get the user consent status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

vendorId

String

The ID of the vendor to check the user consent for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.

Returns

A ConsentStatus object that indicates if the user has given consent or not to the specific vendor and all its required purposes.

ConsentStatus.enable is returned if the user has given consent. ConsentStatus.disable is returned if the user has denied consent.

ConsentStatus.unknown is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable (ie "no consent given") but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for the consent information to be collected.

If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable.

In Objective-C, the return value is an Int and not an Enum. It can take one of the following values:

  • ConsentStatusEnable

  • ConsentStatusDisable

  • ConsentStatusUnknown

Example

Swift
Objective-C
Swift
// IAB vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("1")
// Didomi vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("google")
// Custom vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("c:custom-vendor-id")
Objective-C
Didomi *didomi = [Didomi shared];
// IAB vendors
ConsentStatus iabConsentStatusForVendor = [didomi getUserConsentStatusForVendorAndRequiredPurposesWithVendorId:@"1"];
// Didomi vendors
ConsentStatus didomiConsentStatusForVendor = [didomi getUserConsentStatusForVendorAndRequiredPurposesWithVendorId:@"google"];
// Custom vendors
ConsentStatus customConsentStatusForVendor = [didomi getUserConsentStatusForVendorAndRequiredPurposesWithVendorId:@"c:custom-vendor-id"];

getUserLegitimateInterestStatusForPurpose

Get the user legitimate interest status for a given purpose.

Parameters

Name

Type

Description

purposeId

String

The ID of the purpose to check the user legitimate interest for.

Returns

An enum ConsentStatus (.enable, disable, .unknown) that indicates if the user has allowed, denied, or hasn't set yet legitimate interest data processing to the specific purpose.

getUserLegitimateInterestForVendor

Get the user legitimate interest status for a given vendor. You must also check that the user has allowed legitimate interest data processing for some or all of the purposes required by a vendor before loading the vendor. The function getUserLegitimateInterestStatusForVendorAndRequiredPurposes does all the required checks for you so it might be a better choice.

Parameters

Name

Type

Description

vendorId

String

The ID of the vendor to check the user legitimate interest status for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.

Returns

An enum ConsentStatus (.enable, disable, .unknown) that indicates if the user has allowed, denied, or hasn't set yet legitimate interest data processing to the specific vendor.

getUserLegitimateInterestStatusForVendorAndRequiredPurposes

Get the user legitimate interest status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has allowed legitimate interest data processing for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.

Parameters

Name

Type

Description

vendorId

String

The ID of the vendor to check the user legitimate interest status for.

If you are checking an IAB vendor, pass the number as a String.

If you are checking a custom vendor, prefix your vendor ID with c:.

Returns

An enum ConsentStatus (.enable, disable, .unknown) that indicates if the user has allowed, denied, or hasn't set yet legitimate interest data processing to the specific vendor and its required purposes.

getUserStatus

Get all the user consent status.

Returns

A UserStatus object describing all the available and computed user information.

Parameter

Type

Description

purposes.global.disabled

Set<String>

Computed sets/lists of disabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis.

purposes.global.enabled

Set<String>

Computed sets/lists of enabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis. Purposes considered as essential will be part of the enabled IDs.

purposes.consent.disabled

Set<String>

Disabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.

purposes.consent.enabled

Set<String>

Enabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.

purposes.legitimateInterest.disabled

Set<String>

Disabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.

purposes.legitimateInterest.enabled

Set<String>

Enabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.

purposes.essential

Set<String>

IDs of purposes that are considered essential.

vendors.global.disabled

Set<String>

Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendors.global.enabled

Set<String>

Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendors.globalConsent.disabled

Set<String>

Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendors.globalConsent.enabled

Set<String>

Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendor.globalLegitimateInterest.disabled

Set<String>

Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendor.globalLegitimateInterest.enabled

Set<String>

Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled.

vendor.consent.disabled

Set<String>

Disabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.

vendor.consent.enabled

Set<String>

Enabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.

vendor.legitimateInterest.disabled

Set<String>

Disabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.

vendor.legitimateInterest.enabled

Set<String>

Enabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.

userId

String

Didomi user id.

created

String

User choices creation date.

updated

String

User choices update date.

consentString

String

TFC consent as string.

additionalConsent

String

Additional consent.

Example

Swift
Swift
let userStatus = Didomi.shared.getUserStatus()
// Enabled consent ids for vendors
let enabledVendorsConsentIds = userStatus.vendors.consent.enabled

getUserStatusForVendor

Get the user consent and legitimate interest status for a given vendor.

Parameters

Name

Type

Description

vendorId

String

The ID of the vendor to check the user status for. If you are checking an IAB vendor, pass the number as a String. If you are checking a custom vendor, prefix your vendor ID with c:.

Returns

An enum ConsentStatus (.enable, disable, .unknown) that indicates if the user has allowed both consent and legitimate interest data processing to the specific vendor.

getVendor

Get a vendor based on its ID.

Not available for Objective-C

This function is only exposed to Swift apps and cannot be called from Objective-C.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

vendorId

String

ID of the vendor we want to get.

Returns

Type

Description

Vendor

A Vendor with ID vendorId found in the array of required vendors.

Example

Swift
Swift
Didomi.shared.getVendor(vendorId: "vendor-id")

hideNotice

Hide the consent notice.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.hideNotice()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi hideNotice];

hidePreferences

Hide the preferences popup.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.hidePreferences()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi hidePreferences];

initialize

Initialize the SDK. The initialization runs on a background thread to avoid blocking your UI. Use the onReady function to know when the initialization is done and the SDK is ready to be used.

Requires SDK to be initialized

No.

Parameters

Name

Type

Optional

Description

apiKey

String

No

Your API key

localConfigurationPath

String

Yes

The path to your local config file in your assets/ folder. Defaults to didomi_config.json if null.

remoteConfigurationURL

String

Yes

The URL to a remote configuration file to load during initialization. When provided, the file at the URL will be downloaded and cached to be used instead of the local assets/didomi_config.json. If there is no Internet connection available and no previously cached file, the local file will be used as fallback.

providerId

String

Yes

Your provider ID (if any). A provider ID is assigned when you work with Didomi through a third-party. If are not sure if you have one, set this to null.

disableDidomiRemoteConfig

Boolean

Yes

Prevent the SDK from loading a remote configuration from the Didomi Console. Defaults to true (not loading remote config).

Set this parameter to false to use a remote consent notice configuration loaded from the Didomi Console.

Set this parameter to true to disable loading configurations from the Didomi Console.

languageCode

String

Yes

Language in which the consent UI should be displayed. By default, the consent UI is displayed in the language configured in the device settings. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code or the local code e.g.: "es", "fr", "en_US", "zh_HK", etc.

noticeId

String

Yes

Notice ID to load the configuration from. If provided, the SDK bypasses the app ID targeting and directly loads the configuration from the notice ID.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.initialize(
apiKey: "<Your API key>",
localConfigurationPath: nil,
remoteConfigurationURL: nil,
providerId: nil,
disableDidomiRemoteConfig: false,
languageCode: nil,
noticeId: nil
)
Objective-C
Didomi *didomi = [Didomi shared];
[didomi initializeWithApiKey:@"<Your API key>" localConfigurationPath:nil remoteConfigurationURL:nil providerId:nil disableDidomiRemoteConfig:NO languageCode:nil noticeId:nil];

isConsentRequired

Determine if consent is required for the user. This takes into account the location of the user and the configuration of the SDK:

  • If your app is configured to apply GDPR to all users then this function always returns true.

  • If your app is configured to apply GDPR to EU users only then this function returns true only if the user in the EU.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

Example

Swift
Objective-C
Swift
Didomi.shared.isConsentRequired()
Objective-C
Didomi *didomi = [Didomi shared];
BOOL isConsentRequired = [didomi isConsentRequired];

isUserConsentStatusPartial

Determine if all consent information is available for the user.

This function returns true if and only if:

  • Consent is required for the user (ie the user is in the EU or your tag is configured to apply GDPR to all users)

  • At least one vendor is configured (if there is no vendor configured, this function always returns false as there is no consent to collect)

  • We miss consent information for some vendors or purposes

If there is at least one piece of consent information missing for a single vendor/purpose, this function will return true. The consent notice is usually displayed when this function returns true although there is no guarantee of the direct mapping between the two.

An important edge case is when you add new vendors or if configured vendors ask for new purposes: the consent notice will be displayed again and this function will return true until the user has given or denied consent. Vendors that already had consent before will still operate normally as we only recollect consent for additional vendors/purposes.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

Example

Swift
Objective-C
Swift
Didomi.shared.isUserConsentStatusPartial()
Objective-C
Didomi *didomi = [Didomi shared];
BOOL isUserConsentStatusPartial = [didomi isUserConsentStatusPartial];

isNoticeVisible

Check if the consent notice is currently displayed.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

Example

Swift
Objective-C
Swift
Didomi.shared.isNoticeVisible()
Objective-C
Didomi *didomi = [Didomi shared];
BOOL isNoticeVisible = [didomi isNoticeVisible];

isPreferencesVisible

Check if the preferences popup is currently displayed.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

Example

Swift
Objective-C
Swift
Didomi.shared.isPreferencesVisible()
Objective-C
Didomi *didomi = [Didomi shared];
BOOL isPreferencesVisible = [didomi isPreferencesVisible];

isReady

Check if the SDK is ready.

Requires SDK to be initialized

No.

Parameters

No parameter.

Returns

Bool

Example

Swift
Objective-C
Swift
Didomi.shared.isReady()
Objective-C
Didomi *didomi = [Didomi shared];
BOOL isReady = [didomi isReady];

onError

Add a closure that will be executed if an unexpected situation occurs, for example an error during the initialization process.

Requires SDK to be initialized

No

Parameters

Name

Type

Description

callback

func

A closure executed when an unexpected situation occurs.

Returns

The method itself does not return a value but when the closure is executed an error object is passed to it which explains the reason of the unexpected situation.

We recommend calling this method before calling the initialize method.

Example

Swift
Objective-C
Swift
Didomi.shared.onError { errorEvent in
// Closure executed
}
Objective-C
Didomi *didomi = [Didomi shared];
[didomi onErrorWithCallback:^(DDMErrorEvent * _Nonnull event) {
NSLog(@"An unexpected situation occured.");
}];

onReady

Add an event listener that will be called when the SDK is ready (ie fully initialized). If the event listener is added after the SDK initialization, the listener will be called immediately.

All calls to other functions of this API must only be made in a listener to the ready event to make sure that the SDK is initialized before it is used.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

callback

func

A function to call when the SDK is ready

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.onReady {
// The SDK is ready
}
Objective-C
Didomi *didomi = [Didomi shared];
[didomi onReadyWithCallback:^{
// The SDK is ready
}];

setLogLevel

Set the minimum level of messages to log. The SDK will not log messages under that level. See Logging for more information.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

minLevel

UInt8

Minimum level of messages to log.

Returns

Nothing

Example

Swift
Swift
Didomi.shared.setLogLevel(minLevel: 2)

setupUI

Internally, the setupUI method calls the showNotice method, which calls the shouldConsentBeCollected method. Therefore, by calling the setupUI method, the notice or preferences view will be displayed only if required.

Setup the SDK UI workflows. This method is used to pass a reference to a UIViewController to the SDK that will use it as needed. By calling this method the notice or the preferences views will be displayed only once the SDK is ready and if consent should be collected. This must be called once in your main UIViewController.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

containerController

UIViewController

The controller to use for displaying the notice

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.setupUI(containerController: this)
Objective-C
Didomi *didomi = [Didomi shared];
[didomi setupUIWithContainerController:self];

setUser

Set custom user information from organization

Parameters

Method without authentication :

Name

Type

Description

id

String

Organization ID to associate with the user

Method with authentication :

Name

Type

Description

id

String

Organization ID to associate with the user

algorithm

String

Algorithm used for computing the digest

secretId

String

ID of the secret used for computing the digest

salt

String?

Salt used for computing the digest (optional)

digest

String

Digest of the organization user ID and secret

Returns

Nothing

Example

Didomi.shared.setUser(id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2a")
Didomi.shared.setUser(
id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
algorithm: "hash-md5",
secretId: "secret_id",
salt: "salt",
digest: "098f6bcd4621d373cade4e832627b4f6"
)

showNotice

In most cases this method should be called if the notice should be displayed in response to a user action (e.g.: select the privacy settings section within your app). By calling the setupUI method, the notice will be displayed if required.

Show the consent notice. The consent notice actually only gets shown if needed (consent is required and we are missing consent information for some vendor or purpose).

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.showNotice()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi showNotice];

showPreferences

In most cases this method should be called if you want to show the Preferences screen in response to a user action (the user pressing a "Consent Preferences" button in your app menu, for instance).

Show the Preferences view to the user. This method can be used to allow the user to update their preferences after the notice has been closed. We suggest adding a link/button/item that calls this method somewhere in your app, for example from your settings menu. By default, the Purposes view is displayed first. By calling this method, users will have the opportunity to modify the choices previously made.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

controller

UIViewController

The controller to use for displaying the Preferences

view

Didomi.Views

The view to show (.purposes or .vendors)

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.showPreferences()
Didomi.shared.showPreferences(viewController, .purposes) // Open the Purposes view
Didomi.shared.showPreferences(viewController, .vendors) // Open the Vendors view
Objective-C
Didomi *didomi = [Didomi shared];
[didomi showPreferences];

reset

Reset all the consent information for the current user. This will remove all consent information stored on the device by Didomi and will trigger re-collection of consent. The consent notice will be displayed again.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.reset()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi reset];

setUserAgreeToAll

Report that the user has enabled consents and legitimate interests for all purposes and vendors configured for your app.

This function will log the user choice on our platform and close the notice.

Consent statuses for essential purposes are not stored.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

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

Example

Swift
Objective-C
Swift
Didomi.shared.setUserAgreeToAll()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi setUserAgreeToAll];

setUserConsentStatus

Set the user consent 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 your consent information at once and not one by one.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

enabledPurposeIds

Set<String>

Set of purpose IDs that the user has given consent to

disabledPurposeIds

Set<String>

Set of purpose IDs that the user has not given consent to

enabledVendorIds

Set<String>

Set of vendor IDs that the user has given consent to

disabledVendorIds

Set<String>

Set of vendor IDs that the user has not given consent to

Returns

Bool

true if the user consent status has changed (i.e. the user had given different consent information before this function got called).

Example

Swift
Objective-C
Swift
let didomi = Didomi.shared
didomi.setUserConsentStatus(enabledPurposeIds: ["1", "2"],
disabledPurposeIds: ["3", "4"],
enabledVendorIds: ["1", "2"],
disabledVendorIds: ["3", "4"])
Objective-C
Didomi *didomi = [Didomi shared];
[didomi setUserConsentStatusWithEnabledPurposeIds:[NSSet setWithArray:@[@"1",@"2"]]
disabledPurposeIds:[NSSet setWithArray:@[@"3",@"4"]]
enabledVendorIds:[NSSet setWithArray:@[@"1",@"2"]]
disabledVendorIds:[NSSet setWithArray:@[@"3",@"4"]]];

setUserDisagreeToAll

Report that the user has disabled consents and legitimate interests for all purposes and vendors configured for your app.

This function will log the user choice on our platform and close the notice.

Consent statuses for essential purposes are not stored.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Default

Recommended

Description

consent

Bool

true

true

If true, consent will be set to all entities.

legitimateInterest

Bool

true

true

If true, legitimate interest will be set to all entities.

Returns

Bool

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

Example

Swift
Objective-C
Swift
Didomi.shared.setUserDisagreeToAll()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi setUserDisagreeToAllWithConsent:true legitimateInterest:true];

setUserStatus

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.

Parameters

Global method :

Define a global status for consent purposes, legitimate interest purposes, consent vendors, legitimate interest vendors

Name

Type

Description

purposesConsentStatus

boolean

true if purposes on a consent basis should be enabled, false if they should be disabled

purposesLIStatus

boolean

true if purposes on a legitimate interest basis should be enabled, false if they should be disabled

vendorsConsentStatus

boolean

true if vendors on a consent basis should be enabled, false if they should be disabled

vendorsLIStatus

boolean

true if vendors on a legitimate interest basis should be enabled, false if they should be disabled

Individual purposes / vendors method :

Allows to define precisely which purposes and vendors are enabled / disabled

Name

Type

Description

enabledConsentPurposeIds

Set<String>

Set of purpose IDs that the user has given consent to

disabledConsentPurposeIds

Set<String>

Set of purpose IDs that the user has not given consent to

enabledLIPurposeIds

Set<String>

Set of purpose IDs that the user has allowed legitimate interest processing to

disabledLIPurposeIds

Set<String>

Set of purpose IDs that the user has disallowed legitimate interest processing to

enabledConsentVendorIds

Set<String>

Set of vendor IDs that the user has given consent to.

Prefix custom vendor IDs with c:.

disabledConsentVendorIds

Set<String>

Set of vendor IDs that the user has not given consent to

enabledLIVendorIds

Set<String>

Set of vendor IDs that the user has allowed legitimate interest processing to.

Prefix custom vendor IDs with c:.

disabledLIVendorIds

Set<String>

Set of vendor IDs that the user has not allowed legitimate interest processing to

shouldConsentBeCollected

Determine if consent should be collected for the visitor. Returns true if consent is required for the current user and one of following two conditions is met:

  • Consent has never been collected for this visitor yet

  • New consents 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

Yes.

Parameters

No parameter.

Returns

boolean

Example

Swift
Objective-C
Swift
Didomi.shared.shouldConsentBeCollected()
Objective-C
Didomi *didomi = [Didomi shared];
[didomi shouldConsentBeCollected];

updateSelectedLanguage

Method used to update the selected language of the Didomi SDK and any property that depends on it.

In most cases this method doesn't need to be called. It would only be required for those apps that allow language change on-the-fly, i.e.: from within the app rather than from the device settings.

If your configuration involves country code (en-US), you can provide a locale code to change the regional configuration as well. If only language code (en) is provided and your configuration requires a country code, the country from the device location will be used (and will fallback to the default country if required).

In order to update the language of the views displayed by the Didomi SDK, this method needs to be called before these views are displayed.

Requires SDK to be initialized

Yes.

Parameters

Name

Type

Description

languageCode

String

string containing the 2-letter language code or 5-letter locale code e.g. en, es, fr, en_US, zh_HK, etc.

Returns

Nothing

Example

Swift
Objective-C
Swift
Didomi.shared.onReady {
Didomi.shared.updateSelectedLanguage(languageCode: "en")
}
Objective-C
Didomi *didomi = [Didomi shared];
[didomi onReadyWithCallback:^{
[didomi updateSelectedLanguageWithLanguageCode:@"en"];
}];