Reference - iOS

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. Events listeners allow you to react to different events of interest. This function is safe to call before the ready event has been triggered.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

eventListener

EventListener

The event listener. An instance of a subclass of EventListener

Returns

Nothing

Example

Swift
Objective-C
let didomiEventListener = EventListener()
didomiEventListener.onConsentChanged = { event in
// The consent status of the user has changed
}
didomiEventListener.onHideNotice = { event in
// The notice is being hidden
}
didomiEventListener.onShowNotice = { event in
// The notice is being shown
}
didomiEventListener.onNoticeClickAgree = { event in
// Click on agree on notice
}
didomiEventListener.onNoticeClickMoreInfo = { event in
// Click on learn more on notice
}
didomiEventListener.onPreferencesClickAgreeToAll = { event in
// Click on agree to all on preferences popup
}
didomiEventListener.onPreferencesClickDisagreeToAll = { event in
// Click on disagree to all on preferences popup
}
didomiEventListener.onPreferencesClickSaveChoices = { event in
// Click on save on the purposes view on preferences popup
}
didomiEventListener.onPreferencesClickViewVendors = { event in
// Click view vendors on purposes view on preferences popup
}
didomiEventListener.onPreferencesClickPurposeAgree = { event, purposeId in
// Click on agree to a purpose on preferences popup
}
didomiEventListener.onPreferencesClickPurposeDisagree = { event, purposeId in
// Click on disagree to a purpose on preferences popup
}
didomiEventListener.onPreferencesClickVendorAgree = { event, vendorId in
// Click on agree to a vendor on preferences popup
}
didomiEventListener.onPreferencesClickVendorDisagree = { event, vendorId in
// Click on disagree to a vendor on preferences popup
}
didomiEventListener.onPreferencesClickVendorSaveChoices = { event in
// Click on save on the vendors view on preferences popup
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnConsentChanged:^(enum DDMEventType event) {
// The consent status of the user has changed
}];
[didomiEventListener setOnHideNotice:^(enum DDMEventType event) {
// The notice is being hidden
}];
[didomiEventListener setOnShowNotice:^(enum DDMEventType event) {
// The notice is being shown
}];
[didomiEventListener setOnNoticeClickAgree:^(enum DDMEventType event) {
// Click on agree on notice
}];
[didomiEventListener setOnNoticeClickMoreInfo:^(enum DDMEventType event) {
// Click on learn more on notice
}];
[didomiEventListener setOnPreferencesClickAgreeToAll:^(enum DDMEventType event) {
// Click on agree to all on preferences popup
}];
[didomiEventListener setOnPreferencesClickDisagreeToAll:^(enum DDMEventType event) {
// Click on disagree to all on preferences popup
}];
[didomiEventListener setOnPreferencesClickSaveChoices:^(enum DDMEventType event) {
// Click on save on the purposes view on preferences popup
}];
[didomiEventListener setOnPreferencesClickViewVendors:^(enum DDMEventType event) {
// Click view vendors on purposes view on preferences popup
}];
[didomiEventListener setOnPreferencesClickPurposeAgree:^(enum DDMEventType event, purposeId) {
// Click on agree to a purpose on preferences popup
}];
[didomiEventListener setOnPreferencesClickPurposeDisagree:^(enum DDMEventType event, purposeId) {
// Click on disagree to a purpose on preferences popup
}];
[didomiEventListener setOnPreferencesClickVendorAgree:^(enum DDMEventType event, vendorId) {
// Click on agree to a vendor on preferences popup
}
[didomiEventListener setOnPreferencesClickVendorDisagree:^(enum DDMEventType event, vendorId) {
// Click on disagree to a vendor on preferences popup
}];
[didomiEventListener setOnPreferencesClickVendorSaveChoices:^(enum DDMEventType event) {
// Click on save on the vendors view on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];

Event types

The following events are supported by the Didomi SDK:

Method

Description

onConsentChanged

When a consent is given or withdrawn by the user. Only triggered when the consent status actually changes (ie if the user saves consents without adding/removing any consent then this does not get called).

onHideNotice

When the consent notice is hidden. If you have disabled our default consent notice to replace it with your own, you need to hide your custom notice when this event gets triggered.

onShowNotice

When the consent notice gets displayed. If you have disabled our default consent notices to replace them with your own, you need to show your custom notice when this event gets triggered.

onNoticeClickAgree

When user clicks on agree on the notice

onNoticeClickMoreInfo

When user clicks on learn more on the notice

onPreferencesClickAgreeToAll

When user clicks on agree to all on the preferences popup

onPreferencesClickDisagreeToAll

When user clicks on disagree to all on the preferences popup

onPreferencesClickPurposeAgree

When user agree to a purpose on the preferences popup. (purposeId provided as a parameter)

onPreferencesClickPurposeDisagree

When user disagree to a purpose on the preferences popup. (purposeId provided as a parameter)

onPreferencesClickViewVendors

When user clicks on view vendors on the preferences popup

onPreferencesClickSaveChoices

When user saves his choice on the preferences popup

onPreferencesClickVendorAgree

When user agree to a vendor on the preferences popup. (vendorId provided as a parameter)

onPreferencesClickVendorDisagree

When user disagree to a vendor on the preferences popup. (vendorId provided as a parameter)

onPreferencesClickVendorSaveChoices

When user saves his choice on the vendors view on the preferences popup

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
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
Didomi.shared.getDisabledPurposeIds()
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
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
Didomi.shared.getDisabledVendorIds()
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
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
Didomi.shared.getEnabledPurposeIds()
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
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
Didomi.shared.getEnabledVendorIds()
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
Didomi.shared.getJavaScriptForWebView()
Didomi *didomi = [Didomi shared];
NSString *javaScriptForWebView = [didomi getJavaScriptForWebView];

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
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
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
Didomi.shared.getRequiredPurposeIds()
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
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
Didomi.shared.getRequiredVendorIds()
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
Didomi.shared.getText("key")
Didomi *didomi = [Didomi shared];
NSString *translatedText = [didomi getTextWithKey:@"key"];

getTranslatedText

Method used to get a translated text based on the current language and 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 text that we want to get translated.

Returns

Translated text.

Example

Swift
Objective-C
Didomi.shared.getTranslatedText("key")
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
Didomi.shared.getUserConsentStatusForPurpose("purpose-id")
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
// IAB vendors
Didomi.shared.getUserConsentStatusForVendor("1")
// Didomi vendors
Didomi.shared.getUserConsentStatusForVendor("google")
// Custom vendors
Didomi.shared.getUserConsentStatusForVendor("c:custom-vendor-id")
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
// IAB vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("1")
// Didomi vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("google")
// Custom vendors
Didomi.shared.getUserConsentStatusForVendorAndRequiredPurposes("c:custom-vendor-id")
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"];

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
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
Didomi.shared.hideNotice()
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
Didomi.shared.hidePreferences()
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.

Returns

Nothing

Example

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

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
Didomi.shared.isConsentRequired()
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
Didomi.shared.isUserConsentStatusPartial()
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
Didomi.shared.isNoticeVisible()
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
Didomi.shared.isPreferencesVisible()
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
Didomi.shared.isReady()
Didomi *didomi = [Didomi shared];
BOOL isReady = [didomi isReady];

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
Didomi.shared.onReady {
// The SDK is ready
}
Didomi *didomi = [Didomi shared];
[didomi onReadyWithCallback:^{
// The SDK is ready
}];

setupUI

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

Returns

Nothing

Example

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

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
Didomi.shared.showNotice()
Didomi *didomi = [Didomi shared];
[didomi showNotice];

showPreferences

In most cases this method should be called if the preferences screen 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 preferences screen will be displayed if required.

Show the preferences manager. This can be used to allow the user to update her preferences after the banner has been closed. We suggest adding a link with this function call somewhere app.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Swift
Objective-C
Didomi.shared.showPreferences()
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
Didomi.shared.reset()
Didomi *didomi = [Didomi shared];
[didomi reset];

setUserAgreeToAll

Report that the user has given consent to all purposes and vendors setup for your app programmatically. This function will log the consent on our platform and close the notice.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

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

Example

Swift
Objective-C
Didomi.shared.setUserAgreeToAll()
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 (ie the user had given different consent information before this function got called).

Example

Swift
Objective-C
let didomi = Didomi.shared
didomi.setUserConsentStatus(enabledPurposeIds: ["1", "2"],
disabledPurposeIds: ["3", "4"],
enabledVendorIds: ["1", "2"],
disabledVendorIds: ["3", "4"])
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 denied consent to all purposes and vendors setup for your app programmatically. This function will log the consent information on our platform and close the banner.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

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

Example

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

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
Didomi.shared.shouldConsentBeCollected()
Didomi *didomi = [Didomi shared];
[didomi shouldConsentBeCollected];