Didomi - Developers documentation
  • Introduction
  • SDKs
    • Introduction
    • Web SDK
      • Getting started
      • Tags and vendors management
        • Tags management
          • Events & Variables
            • Deprecated
            • Custom events
          • Tag managers
            • Adobe Launch/DTM
            • Eulerian
            • Google Tag Manager
              • Configure the Didomi / GTM integration
              • Didomi's GTM template
            • Tealium
            • Other tag managers
        • Custom Didomi <script> tags
        • Third-party integrations
          • Google Ad Manager / AdSense
            • GDPR via Non-Personalized Ads
              • Share consent and load/refresh ads
              • Share consent without loading or refreshing ads
            • US states laws
          • Google Consent Mode V2
          • Kameleoon
          • Piano Analytics (AT Internet)
          • Prebid
            • GDPR via IAB TCF
            • US states laws
          • Salesforce DMP (Krux)
        • IAB frameworks
        • Programmatic API
      • Configuration
        • Bots (SEO & Performance tools)
        • Configuration by URL
        • Cookies and storage
        • Custom domains for events
        • Notice
          • Behavior
          • Interactions
          • Look and feel
        • Preferences
        • Theme
      • AB tests
      • Custom domain
        • Domain delegation
        • Reverse proxy
      • Share consents between domains
      • Share consents across devices
      • Pass user choices in query string
      • Serve Didomi assets from your domain
      • Reference
        • API
          • Deprecated
        • Events
      • Performance
      • Versions
    • Mobile and TV SDKs
      • Android and Android TV
        • Setup
        • Logging
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • iOS and tvOS
        • Setup
        • Logging
        • App Tracking Transparency (iOS 14.5+)
        • Reference
          • API
            • Deprecated
          • Events
        • Versions
      • Unity
        • Setup
        • Reference
        • Versions
        • Troubleshooting
      • React Native
        • Setup
        • Reference
          • Deprecated
        • Versions
      • Flutter
        • Setup
        • Reference
        • Versions
      • Consent notice
        • Getting started
        • Customize the notice
        • Customize the preferences popup
        • Customize the theme & UI
        • Load notice by ID
      • Third-party SDKs
      • Share consents across devices
      • Share consent with WebViews
      • Google Consent Mode v2
      • FAQ
    • AMP SDK
      • Blocking Behaviors
        • Load immediately on page load
        • Load only after consent (positive or negative)
        • Load only after positive consent
      • Consent status for vendors
    • Help & Support
  • API
    • Introduction
      • Authentication
      • Errors
      • Pagination
      • Filters
      • Caching
      • Rate limiting
      • Quotas
      • Translations
    • Data Manager
      • Regulations
      • Configuration Tree
      • Purposes
        • Purposes & Vendors Numerical IDs
      • Preferences Library
      • User Rights
    • Widgets
      • Consent notices
        • Notices
        • Configurations
        • Multi-Regulation Configurations
          • Migration of Existing Notices and API Updates
        • Deployments
        • Tutorials
          • Create and publish a consent notice
          • Create and publish a multi-regulation consent notice
      • Privacy widgets
        • Create a widget
        • Retrieve widgets
        • Edit a widget
          • Content & Design
            • Themes & Shapes
            • Components
              • auth
              • dsar_form
              • footer
              • header
              • preference
              • preference_value
              • save
              • section
              • sections
            • Options
          • Purposes & preferences
          • Settings
        • Deploy a Widget
          • Use your own subdomain
          • Use your own domain
          • Implement an embeddable widget on your website
        • Authentication
          • Manage authentication providers
          • Authenticate your end-user
        • Archive a widget
        • Headless widgets
          • Public Methods
          • Custom elements
          • Custom events
          • Event listeners
        • Tutorial
          • Launch a Preference Center from a mobile app
    • Compliance Reports
      • Properties
      • Reports
      • CSV format reference
      • Websites
    • Consents and Preferences
      • Events
        • Generate IAB TCF consent string
      • Links
      • Proofs
      • Tokens
      • Secrets
      • Users
      • Tutorial
        • Collect and operate data
    • Privacy Requests
      • Requests
      • Notes
      • Links
      • Emails
  • Integrations
    • Introduction
      • Quotas
    • Generic integrations
      • Batch export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
        • Exported data
          • Notices consents
        • Logs
      • Webhooks
      • Batch import
      • Analytics export
        • Destinations
          • AWS S3 Bucket (owned by Didomi)
          • GCP Storage Bucket
    • Third-party apps
      • CMP integrations
        • Didomi-mParticle integration for your CMP
        • Deploy Didomi’s SDK for your Adobe Commerce website
      • Preference Management Platform integrations
        • Actito
        • Adobe Campaign Classic
        • Adobe Experience Cloud
        • Adobe Marketo Engage
        • Adobe Source Connector
        • Braze
        • Dotdigital
        • Hubspot
        • Mailchimp
        • Microsoft Dynamics 365
        • Salesforce Marketing Cloud
        • Salesforce Sales & Service Cloud
        • Selligent
        • Brevo (ex Sendinblue)
    • Tutorials
      • Configure a HTTP webhook
      • Configure a batch export
      • Configure an analytics export
    • Emailing
      • Configurations
        • Actito Email
        • Actito SMS
        • Adobe Campaign Classic
        • Adobe Campaign Standard
      • Emails
        • Templates
        • Manage your templates
Powered by GitBook
On this page
  • Usage
  • addEventListener
  • removeEventListener
  • getJavaScriptForWebView
  • getQueryStringForWebView
  • hideNotice
  • hidePreferences
  • initialize
  • isNoticeVisible
  • isPreferencesVisible
  • isReady
  • onError
  • onReady
  • setLogLevel
  • setupUI
  • showNotice
  • showPreferences
  • updateSelectedLanguage
  • Notice Config
  • getPurpose
  • getRequiredPurposes
  • getRequiredVendors
  • getText
  • getTranslatedText
  • getVendor
  • getTotalVendorCount
  • getIABVendorCount
  • getNonIABVendorCount
  • User Status
  • applicableRegulation
  • addVendorStatusListener
  • removeVendorStatusListener
  • getCurrentUserStatus
  • isUserStatusPartial
  • openCurrentUserStatusTransaction
  • reset
  • setCurrentUserStatus
  • setUserAgreeToAll
  • setUserDisagreeToAll
  • shouldUserStatusBeCollected
  • setUser
  • clearUser
  1. SDKs
  2. Mobile and TV SDKs
  3. iOS and tvOS
  4. Reference

API

PreviousReferenceNextDeprecated

Last updated 2 months ago

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 ).

Usage

addEventListener

Add an event listener to catch events triggered by the SDK.

removeEventListener

Remove a previously added event listener.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

eventListener

EventListener

The event listener to remove.

Returns

Nothing

Example

Didomi.shared.removeEventListener(listener: currentEventListener)

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

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

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

Didomi.shared.getQueryStringForWebView()
Didomi *didomi = [Didomi shared];
NSString *queryStringForWebView = [didomi getQueryStringForWebView];

hideNotice

Hide the consent notice.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

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

Didomi.shared.hidePreferences()
Didomi *didomi = [Didomi shared];

[didomi hidePreferences];

initialize

Requires SDK to be initialized

No.

Parameter:

Name

Type

parameters

DidomiInitializeParameters

Description for DidomiInitializeParameters

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 (deprecated)

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.

countryCode

String

Yes

Override user country code when determining the privacy regulation to apply.

Keep null to let the Didomi SDK determine the user country.

regionCode

String

Yes

Override user region code when determining the privacy regulation to apply.

Keep null to let the Didomi SDK determine the user region.

Ignored if countryCode is not set.

isUnderage

Boolean

Yes

Whether the user is underage or not. This parameters can only be used if the Underage feature has been configured in your notice. (Underage is currently in beta version).

Returns

Nothing

Example

let parameters = DidomiInitializeParameters(
    apiKey: "<Your API key>",
    noticeID: "<Your notice ID>"
)
initialize(parameters)
DidomiInitializeParameters *parameters = [[DidomiInitializeParameters alloc] initWithApiKey: @"<Your API key>"
                                                                         localConfigurationPath: nil
                                                                         remoteConfigurationURL: nil
                                                                                     providerID: nil
                                                                      disableDidomiRemoteConfig: NO
                                                                                   languageCode: nil
                                                                                       noticeID: @"<Your Notice ID>"];
    
[didomi initialize: parameters];

isNoticeVisible

Check if the consent notice is currently displayed.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Bool

Example

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

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

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

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

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

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

setLogLevel

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

minLevel

UInt8

Minimum level of messages to log.

Returns

Nothing

Example

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

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

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

We strongly advise you to always pass the viewController parameter unless you can be certain that setupUI has been called.

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

Didomi.shared.showPreferences()
Didomi.shared.showPreferences(viewController, .purposes) // Open the Purposes view
Didomi.shared.showPreferences(viewController, .vendors) // Open the Vendors view
Didomi.shared.showPreferences(viewController, .sensitivePersonalInformation) // Open the Sensitive Personal Information view
Didomi *didomi = [Didomi shared];
// We use `self` assuming this method is called from a `UIViewController`
[didomi showPreferencesWithController:self view:ViewsPurposes];

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

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


Notice Config

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

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

Didomi.shared.getRequiredPurposes()

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

Didomi.shared.getRequiredVendors()

getText

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

Didomi.shared.getText("key")
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

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

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

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

getTotalVendorCount

Get the total count of required vendors.

Requires SDK to be initialized

Yes.

Returns

Type

Description

Int

The total vendor count

Example

Didomi.shared.getTotalVendorCount();
Didomi *didomi = [Didomi shared];

[didomi getTotalVendorCount];

getIABVendorCount

Get the count of required IAB vendors.

Requires SDK to be initialized

Yes.

Returns

Type

Description

Int

The IAB vendor count

Example

Didomi.shared.getIABVendorCount();
Didomi *didomi = [Didomi shared];

[didomi getIABVendorCount];

getNonIABVendorCount

Get the count of required vendors which are not part of the IAB.

Requires SDK to be initialized

Yes.

Returns

Type

Description

Int

The non-IAB vendor count

Example

Didomi.shared.getNonIABVendorCount();
Didomi *didomi = [Didomi shared];

[didomi getNonIABVendorCount];

User Status

applicableRegulation

Get the applicable regulation.

Requires SDK to be initialized

yes.

Returns

Type
Description

Enum

Representation of the current regulation as a Regulation enum value, such as .gdpr, .cpra or .none.

Note that some regulations present as enum values are not available yet.

Example

let regulation = Didomi.shared.applicableRegulation
NSString *regulation = [Didomi.shared applicableRegulation];

addVendorStatusListener

Listen for changes on the user status linked to a specific vendor.

Requires SDK to be initialized

No.

Parameters

Name
Type
Description

id

String

The ID of the vendor for which we want to start listening for changes.

This ID should be the ID provided by Didomi, which doesn't contain prefixes.

callback

callback: (CurrentUserStatus.VendorStatus) -> Void

Callback that will be executed whenever changes are detected on the specified vendor. When this callback is executed, the status linked to the specified vendor will be passed.

Returns

Nothing

Example

Didomi.shared.addVendorStatusListener(id: "vendor-id") { newStatus in
  print("Vendor Status changed. New status: \(newStatus)")
}
[[Didomi shared] addVendorStatusListenerWithId:@"vendor-id" :^(DDMCurrentUserStatusVendor *newStatus) {
  NSLog(@"Vendor Status changed. New status: %@", newStatus);
}];

removeVendorStatusListener

Stop listening for changes on the user status linked to a specific vendor.

Requires SDK to be initialized

No.

Parameters

Name
Type
Description

id

String

The ID of the vendor for which we want to stop listening for changes.

This ID should be the ID provided by Didomi, which doesn't contain prefixes.

Returns

Nothing

Example

Didomi.shared.removeVendorStatusListener(id: "vendor-id")

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

  • Dictionary that maps the ID of a vendor to an object representing its status.

  • The IDs used in this dictionary correspond to the Didomi IDs i.e.: without the c: or any other prefix.

  • 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

  • Dictionary 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

enum

  • Representation of the current regulation as a Regulation enum value, such as .gdpr, .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.

gppString

string

GPP string. Note: GPP feature is currently in beta version.

shouldUserStatusBeCollected()

Boolean

Determine if the User Status (consent) should be collected or not, based on regulation, expiration date, and user status at the time of the call to Didomi#getCurrentUserStatus(). This method is only valid for objects returned by Didomi after a call to getCurrentUserStatus(). Not available in Objective-C.

Examples

let currentUserStatus = Didomi.shared.getCurrentUserStatus()

// Example: get consent status for vendor `google`
let vendorStatus = currentUserStatus.vendors["google"]
let isVendorEnabled = vendorStatus.enabled

// Example: get consent status for custom vendor
// with ID `custom-vendor-id` (without `c:` prefix).
let customVendorStatus = currentUserStatus.vendors["custom-vendor-id"]
let isCustomVendorEnabled = customVendorStatus.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];

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.

Examples

Didomi.shared.isUserStatusPartial()
Didomi *didomi = [Didomi shared];
BOOL isUserStatusPartial = [didomi isUserStatusPartial];

openCurrentUserStatusTransaction

Definition

Create an instance of the CurrentUserStatusTransaction class.

This class provides mechanisms to stage updates to the user status regarding purposes and vendors, allowing for batch operations.

Updates made through its methods are queued and applied simultaneously to the user status only once the commit method of the returned object is called.

Additional details:

  • The status of vendors and purposes whose IDs are not not specified through the methods provided by CurrentUserStatusTransaction are kept unchanged.

  • Essential purposes are always set to enabled and can’t be updated by the methods provided by CurrentUserStatusTransaction.

  • When the regulation applied for a user is none, the methods provided by CurrentUserStatusTransaction should not update the status of any vendor or purpose which will always remain as enabled. When the commit method is called it will return false.

  • If the IDs that are passed through the methods provided by CurrentUserStatusTransaction don’t correspond to vendors or purposes required by the Notice Config, they will be ignored.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

An instance of the CurrentUserStatusTransaction class.

Description of the CurrentUserStatusTransaction class

Method
Parameters
Returns
Description

enablePurpose

id (String): ID of the purpose to be enabled.

Current CurrentUserStatusTransaction object.

Enable a single purpose based on its ID.

enablePurposes

ids ([String]): IDs of the purposes to be enabled.

Current CurrentUserStatusTransaction object.

Enable multiple purposes based on their IDs.

disablePurpose

id (String): ID of the purpose to be disabled.

Current CurrentUserStatusTransaction object.

Disable a single purpose based on its ID.

disablePurposes

ids ([String]): IDs of the purposes to be disabled.

Current CurrentUserStatusTransaction object.

Disable multiple purposes based on their IDs.

enableVendor

id (String): Didomi ID of the vendor to be enabled.

Current CurrentUserStatusTransaction object.

Enable a single vendor based on its Didomi ID.

enableVendors

ids ([String]): Didomi IDs of the vendors to be enabled.

Current CurrentUserStatusTransaction object.

Enable multiple vendors based on their Didomi IDs.

disableVendor

id (String): Didomi ID of the vendor to be disabled.

Current CurrentUserStatusTransaction object.

Disable a single vendor based on its Didomi ID.

disableVendors

ids ([String]): Didomi IDs of the vendors to be disabled.

Current CurrentUserStatusTransaction object.

Disable multiple vendors based on their Didomi IDs.

commit

No parameters.

Bool: true if user status has been updated, false otherwise.

Commit the changes that have been made through other methods.

Examples

let didomi = Didomi.shared
let transaction = didomi.openCurrentUserStatusTransaction()

// enable a purpose
transaction.enablePurpose("cookies")
// enable purposes
transaction.enablePurpose(["cookies", "analytics"])
// disable a purpose
transaction.enablePurpose("analytics")
// disable purposes
transaction.disablePurposes(["cookies", "analytics"])
// enable a vendor
transaction.enableVendor("vendor-1")
// enable vendors
transaction.enableVendors(["vendor-1","vendor-2"])
// disable a vendor
transaction.disableVendor("vendor-1")
// disable vendors
transaction.disableVendors(["vendor-1", "vendor-1"])

// Chain multiple calls
transaction.enablePurpose("cookies").disablePurpose("analytics")

// Save user choices
let updated = transaction.commit()
Didomi *didomi = [Didomi shared];
CurrentUserStatusTransaction *transaction = [didomi openCurrentUserStatusTransaction];

// Enable a purpose
[transaction enablePurpose:@"cookies"];
// Enable purposes
[transaction enablePurposes:@[@"cookies", @"analytics"]];
// Disable a purpose
[transaction disablePurpose:@"analytics"];
// Disable purposes
[transaction disablePurposes:@[@"cookies", @"analytics"]];
// Enable a vendor
[transaction enableVendor:@"vendor-1"];
// Enable vendors
[transaction enableVendors:@[@"vendor-1", @"vendor-2"]];
// Disable a vendor
[transaction disableVendor:@"vendor-1"];
// Disable vendors
[transaction disableVendors:@[@"vendor-1", @"vendor-2"]];

// Chain multiple calls
[[transaction enablePurpose:@"cookies"] disablePurpose:@"analytics"];

// Save user choices
BOOL updated = [transaction commit];

reset

Definition

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 when setupUI is called.

If the SDK is not initialized when this method is called, the reset will be performed during SDK initialization.

Requires SDK to be initialized

No.

Parameters

No parameter.

Returns

Nothing

Example

Didomi.shared.reset()
Didomi *didomi = [Didomi shared];
[didomi reset];

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.

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).

Examples

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];

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

Didomi.shared.setUserAgreeToAll()
Didomi *didomi = [Didomi shared];
[didomi setUserAgreeToAll];

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.

Returns

Bool

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

Example

Didomi.shared.setUserDisagreeToAll()
Didomi *didomi = [Didomi shared];
[didomi setUserDisagreeToAll];

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

Examples

Didomi.shared.shouldUserStatusBeCollected()
Didomi *didomi = [Didomi shared];
[didomi shouldUserStatusBeCollected];

setUser

The setUser function is used to configure settings specific to the user currently navigating the mobile app. It can be used in various scenarios, such as:

  • Authenticating the user.

  • Setting user-specific attributes, like identifying the user as underage.

Parameter:

Name
Type
Description

parameters

DidomiUserParameters

Object containing properties required to set a user.

Description for DidomiUserParameters:

Name
Type
Description

userAuth

UserAuth

User authentication object. Can be either UserAuthWithoutParams, UserAuthWithEncryptionParams or UserAuthWithHashParams.

dcsUserAuth

UserAuthParams?

Optional. Dedicated user with encryption or hash used for Didomi Consent String signature. Can be either UserAuthWithEncryptionParams or UserAuthWithHashParams. This parameter can only be used if you are using the Didomi Consent String feature (This feature is currently in beta version)

containerController

UIViewController?

Optional. Activity of the application if the notice should be displayed when the consent expired or the user is new.

isUnderage

Boolean?

Optional. Whether the user is underage or not. This parameters can only be used if the Underage feature has been configured in your notice. (Underage is currently in beta version).

Parameters for UserAuthWithoutParams :

Name
Type
Description

id

String

Organization ID to associate with the user.

Parameters for UserAuthWithEncryptionParams :

Name
Type
Description

id

String

Organization ID to associate with the user.

algorithm

String

Algorithm used for computing the user ID.

secretId

String

ID of the secret used for the computing the user ID.

initializationVector

String

Initialization Vector used for encrypting the message.

expiration

TimeInterval?

Optional. Expiration time as UNIX timestamp (must be > 0).

Parameters for UserAuthWithHashParams :

Name
Type
Description

id

String

Organization ID to associate with the user.

algorithm

String

Algorithm used for computing the user ID.

secretId

String

ID of the secret used for the computing the user ID.

digest

String

Digest used for representing the user ID

salt

String?

Optional. Salt used for computing the user ID.

expiration

TimeInterval?

Optional. Expiration time as UNIX timestamp (must be > 0)

Returns

Nothing

Example

Didomi.shared.setUser(DidomiUserParameters(
            userAuth: UserAuthWithoutParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2a"
            ), // user ID
            dcsUserAuth: UserAuthWithEncryptionParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2b",
                        algorithm: "algorithm",
                        secretID: "secret_id",
                        initialisationVector: "initialization_vector",
                        expiration: 10000 // or null
            ), // optional DCS user authentication
            containerController: viewController, // optional View Controller
            isUnderage: true // optional underage flag
));

Didomi.shared.setUser(DidomiUserParameters(
            userAuth: UserAuthWithEncryptionParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
                        algorithm: "algorithm",
                        secretID: "secret_id",
                        initialisationVector: "initialization_vector",
                        expiration: 10000 // or nil
            ), // user authentication
            dcsUserAuth: UserAuthWithEncryptionParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2b",
                        algorithm: "algorithm",
                        secretID: "secret_id",
                        initialisationVector: "initialization_vector",
                        expiration: 10000 // or nil
            ), // optional DCS user authentication
            containerController: viewController, // optional View Controller
            isUnderage: true // optional underage flag
));

Didomi.shared.setUser(DidomiUserParameters(
            userAuth: UserAuthWithHashParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
                        algorithm: "algorithm",
                        secretID: "secret_id",
                        digest: "digest",
                        salt: "salt", // or nil
                        expiration: 10000 // or nil
            ), // user authentication
            dcsUserAuth: UserAuthWithHashParams(
                        id: "e3222031-7c45-4f4a-8851-ffd57dbf0a2b",
                        algorithm: "algorithm",
                        secretID: "secret_id",
                        digest: "digest",
                        salt: "salt", // or nil
                        expiration: 10000 // or nil
            ), // optional DCS user authentication
            containerController: viewController, // optional View Controller
            isUnderage: true // optional underage flag
));
DidomiUserParameters *params1 = [[DidomiUserParameters alloc] initWithUserAuth:
    [[UserAuthWithoutParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2a"]
    dcsUserAuth:[[UserAuthWithEncryptionParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2b"
                                                     algorithm: @"algorithm"
                                                     secretID: @"secret_id"
                                        initialisationVector: @"initialization_vector"
                                                   expiration: @10000]
    containerController: viewController
    isUnderage: @(YES)];
[[Didomi shared] setUser: params1];

DidomiUserParameters *params2 = [[DidomiUserParameters alloc] initWithUserAuth:
    [[UserAuthWithEncryptionParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2a"
                                           algorithm: @"algorithm"
                                           secretID: @"secret_id"
                              initialisationVector: @"initialization_vector"
                                         expiration: @10000]
    dcsUserAuth:[[UserAuthWithEncryptionParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2b"
                                                     algorithm: @"algorithm"
                                                     secretID: @"secret_id"
                                        initialisationVector: @"initialization_vector"
                                                   expiration: @10000]
    containerController: viewController
    isUnderage: @(YES)];
[[Didomi shared] setUser: params2];

DidomiUserParameters *params3 = [[DidomiUserParameters alloc] initWithUserAuth:
    [[UserAuthWithHashParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2a"
                                     algorithm: @"algorithm"
                                     secretID: @"secret_id"
                                       digest: @"digest"
                                         salt: @"salt"
                                   expiration: @10000]
    dcsUserAuth:[[UserAuthWithHashParams alloc] initWithId: @"e3222031-7c45-4f4a-8851-ffd57dbf0a2b"
                                               algorithm: @"algorithm"
                                               secretID: @"secret_id"
                                                 digest: @"digest"
                                                   salt: @"salt"
                                             expiration: @10000]
    containerController: viewController
    isUnderage: @(YES)];
[[Didomi shared] setUser: params3];

clearUser

Remove custom user information from organization. This will also reset the Didomi User ID.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Examples

Didomi.shared.clearUser()
Didomi *didomi = [Didomi shared];
[didomi clearUser];

Read our article on for more information.

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

The parameter disableDidomiRemoteConfig is deprecated, we strongly suggest you to create your notice from the console (see for more information).

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

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 .

Custom texts for the consent notice:

Custom texts for the preferences:

Custom texts for custom notices:

Please read on what to expect from your analytics when setting a custom behavior for your consent notice.

Please read on what to expect from your analytics when setting a custom behavior for your consent notice.

Please read on what to expect from your analytics when setting a custom behavior for your consent notice.

Enabling cross-device functionality. For detailed information, see .

sharing consent with WebViews
Logging
https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-theme#translatable-texts-for-custom-notices
https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-notice#texts
https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-preferences-popup#text
https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-theme#translatable-texts-for-custom-notices
our article
our article
our article
documentation
See the dedicated section for more details
onReady
onReady
Setup fromThe Console