Package 

Class Didomi

  • All Implemented Interfaces:

    
    public final class Didomi
    
                        
    • Constructor Detail

    • Method Detail

      • isError

         final Boolean isError()

        Has an error occurred during SDK initialization.

      • getDisabledPurposes

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().") final Set<Purpose> getDisabledPurposes()
      • getEnabledPurposes

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getPurposes().getGlobal().getEnabled().") final Set<Purpose> getEnabledPurposes()
      • getDisabledPurposeIds

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().") final Set<String> getDisabledPurposeIds()
      • getEnabledPurposeIds

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getPurposes().getGlobal().getEnabled().") final Set<String> getEnabledPurposeIds()
      • getDisabledVendors

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getDisabled().") final Set<Vendor> getDisabledVendors()
      • getEnabledVendors

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getEnabled().") final Set<Vendor> getEnabledVendors()
      • getDisabledVendorIds

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getDisabled().") final Set<String> getDisabledVendorIds()
      • getEnabledVendorIds

        @Deprecated(message = "use {@link #getUserStatus()} instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getEnabled().") final Set<String> getEnabledVendorIds()
      • setLogLevel

         final Unit setLogLevel(Integer minLevel)

        Set the minimum level of messages to log

        Messages with a level below minLevel will not be logged. Levels are standard levels from android.util.Log (https://developer.android.com/reference/android/util/Log#constants_1):

        • android.util.Log.VERBOSE (2)

        • android.util.Log.DEBUG (3)

        • android.util.Log.INFO (4)

        • android.util.Log.WARN (5)

        • android.util.Log.ERROR (6)

        We recommend setting android.util.Log.WARN in production

        Parameters:
        minLevel - Minimum level of messages to log
      • ready

         final Boolean ready()

        Internal use only. Method used to check if the SDK is ready (required for unit tests).

      • readyOrThrow

         final Unit readyOrThrow()

        Method used to check if the SDK is ready.

      • initialize

        @Deprecated(message = "Use {@link #initialize(Application, DidomiInitializeParameters)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "this.initialize(Application, DidomiInitializeParameters)"))@JvmOverloads() final Unit initialize(Application application, String apiKey, String localConfigurationPath, String remoteConfigurationUrl, String providerId, Boolean disableDidomiRemoteConfig, String languageCode, String noticeId)

        Initialize the Didomi SDK and load its configuration. This method should be called from your Application onCreate method.

        Parameters:
        application - The application instance; this is used to access resources within the application's file access and preferences.
        apiKey - Your API key.
        localConfigurationPath - Path to client specific config file in JSON format.
        remoteConfigurationUrl - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
        disableDidomiRemoteConfig - Used to disable remote configuration.
        languageCode - Language in which the consent UI should be displayed.
        noticeId - ID of the notice configuration to load if your are not using app ID targeting
      • initialize

        @Deprecated(message = "Use {@link #initialize(Application, DidomiInitializeParameters)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "this.initialize(Application, DidomiInitializeParameters)"))@JvmOverloads() final Unit initialize(Application application, String apiKey, String localConfigurationPath, String remoteConfigurationUrl, String providerId, Boolean disableDidomiRemoteConfig, String languageCode)

        Initialize the Didomi SDK and load its configuration. This method should be called from your Application onCreate method.

        Parameters:
        application - The application instance; this is used to access resources within the application's file access and preferences.
        apiKey - Your API key.
        localConfigurationPath - Path to client specific config file in JSON format.
        remoteConfigurationUrl - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
        disableDidomiRemoteConfig - Used to disable remote configuration.
        languageCode - Language in which the consent UI should be displayed.
      • initialize

        @Deprecated(message = "Use {@link #initialize(Application, DidomiInitializeParameters)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "this.initialize(Application, DidomiInitializeParameters)"))@JvmOverloads() final Unit initialize(Application application, String apiKey, String localConfigurationPath, String remoteConfigurationUrl, String providerId, Boolean disableDidomiRemoteConfig)

        Initialize the Didomi SDK and load its configuration. This method should be called from your Application onCreate method.

        Parameters:
        application - The application instance; this is used to access resources within the application's file access and preferences.
        apiKey - Your API key.
        localConfigurationPath - Path to client specific config file in JSON format.
        remoteConfigurationUrl - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
        disableDidomiRemoteConfig - Used to disable remote configuration.
      • initialize

        @Deprecated(message = "Use {@link #initialize(Application, DidomiInitializeParameters)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "this.initialize(Application, DidomiInitializeParameters)"))@JvmOverloads() final Unit initialize(Application application, String apiKey, String localConfigurationPath, String remoteConfigurationUrl, String providerId)

        Initialize the Didomi SDK and load its configuration. This method should be called from your Application onCreate method.

        Parameters:
        application - The application instance; this is used to access resources within the application's file access and preferences.
        apiKey - Your API key.
        localConfigurationPath - Path to client specific config file in JSON format.
        remoteConfigurationUrl - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
      • initialize

         final Unit initialize(Application application, DidomiInitializeParameters parameters)

        Initialize the Didomi SDK and load its configuration. This method should be called from your Application onCreate method.

        Parameters:
        application - The application instance; this is used to access resources within the application's file access and preferences.
        parameters - DidomiInitializeParameters object specifying parameters to initialize the SDK.
      • shouldConsentBeCollected

         final Boolean shouldConsentBeCollected()

        Check if the consent should be collected depending on if we have any consents or if we have some consents but the number of days before displaying the notice again has not expired yet

      • getUserConsentStatusForPurpose

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the purposeId in getUserStatus().getPurposes().getConsent().getEnabled() or getUserStatus().getPurposes().getConsent().getDisabled().") final Boolean getUserConsentStatusForPurpose(String purposeId)

        Get the user consent status for a specific purpose

      • getUserLegitimateInterestStatusForPurpose

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the purposeId in getUserStatus().getPurposes().getLegitimateInterest().getEnabled() or getUserStatus().getPurposes().getLegitimateInterest().getDisabled().") final Boolean getUserLegitimateInterestStatusForPurpose(String purposeId)

        Get the user legitimate interest status for a specific purpose

      • getUserConsentStatusForVendor

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the vendorId in getUserStatus().getVendors().getConsent().getEnabled() or getUserStatus().getVendors().getConsent().getDisabled().") final Boolean getUserConsentStatusForVendor(String vendorId)

        Get the user consent status for a specific vendor

      • getUserLegitimateInterestStatusForVendor

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the vendorId in getUserStatus().getVendors().getLegitimateInterest().getEnabled() or getUserStatus().getVendors().getLegitimateInterest().getDisabled().") final Boolean getUserLegitimateInterestStatusForVendor(String vendorId)

        Get the user legitimate interest status for a specific vendor

      • getUserStatusForVendor

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the vendorId in getUserStatus().getVendors().getGlobal().getEnabled() or getUserStatus().getVendors().getGlobal().getDisabled().") final Boolean getUserStatusForVendor(String vendorId)

        Get the user consent and legitimate interest status for a specific vendor

      • getUserConsentStatusForVendorAndRequiredPurposes

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the vendorId in getUserStatus().getVendors().getGlobalConsent().getEnabled() or getUserStatus().getVendors().getGlobalConsent().getDisabled().") final Boolean getUserConsentStatusForVendorAndRequiredPurposes(String vendorId)

        Check if a vendor has consent for all the purposes that it requires

      • getUserLegitimateInterestStatusForVendorAndRequiredPurposes

        @Deprecated(message = "use {@link #getUserStatus()} instead. Search the vendorId in getUserStatus().getVendors().getGlobalLegitimateInterest().getEnabled() or getUserStatus().getVendors().getGlobalLegitimateInterest().getDisabled().") final Boolean getUserLegitimateInterestStatusForVendorAndRequiredPurposes(String vendorId)

        Check if a vendor has consent for all the legitimate interest purposes that it requires

      • setUserDisagreeToAll

         final Boolean setUserDisagreeToAll()

        Update user status to disagree : disable consent and legitimate interest purposes, disable consent vendors, but still enable legitimate interest vendors.

      • setUserConsentStatus

        @Deprecated(message = "Use {@link #setUserStatus(Set, Set, Set, Set, Set, Set, Set, Set)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUserStatus(enabledPurposeIds, disabledPurposeIds, enabledLegitimatePurposeIds, disabledLegitimatePurposeIds, enabledVendorIds, disabledVendorIds, enabledLegIntVendorIds, disabledLegIntVendorIds)")) final Boolean setUserConsentStatus(Set<String> enabledPurposeIds, Set<String> disabledPurposeIds, Set<String> enabledLegitimatePurposeIds, Set<String> disabledLegitimatePurposeIds, Set<String> enabledVendorIds, Set<String> disabledVendorIds, Set<String> enabledLegIntVendorIds, Set<String> disabledLegIntVendorIds)
      • setUserStatus

        @Deprecated(message = "This internal function should not be used, use {@link #setUserStatus(Set, Set, Set, Set, Set, Set, Set, Set)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUserStatus(enabledPurposeIds, disabledPurposeIds, enabledLegitimatePurposeIds, disabledLegitimatePurposeIds, enabledVendorIds, disabledVendorIds, enabledLegIntVendorIds, disabledLegIntVendorIds)")) final Boolean setUserStatus(Set<String> enabledConsentPurposeIds, Set<String> disabledConsentPurposeIds, Set<String> enabledLIPurposeIds, Set<String> disabledLIPurposeIds, Set<String> enabledConsentVendorIds, Set<String> disabledConsentVendorIds, Set<String> enabledLIVendorIds, Set<String> disabledLIVendorIds, Boolean sendAPIEvent)
      • setUserStatus

         final Boolean setUserStatus(Set<String> enabledConsentPurposeIds, Set<String> disabledConsentPurposeIds, Set<String> enabledLIPurposeIds, Set<String> disabledLIPurposeIds, Set<String> enabledConsentVendorIds, Set<String> disabledConsentVendorIds, Set<String> enabledLIVendorIds, Set<String> disabledLIVendorIds)

        Set the user status for each purpose and vendor

        Parameters:
        enabledConsentPurposeIds - ids of the consent purposes to enable
        disabledConsentPurposeIds - ids of the consent purposes to disable
        enabledLIPurposeIds - ids of the legitimate interest purposes to enable
        disabledLIPurposeIds - ids of the legitimate interest purposes to disable
        enabledConsentVendorIds - ids of the consent vendors to enable
        disabledConsentVendorIds - ids of the consent vendors to disable
        enabledLIVendorIds - ids of the legitimate interest vendors to enable
        disabledLIVendorIds - ids of the legitimate interest vendors to disable
      • setUserStatus

         final Boolean setUserStatus(Boolean purposesConsentStatus, Boolean purposesLIStatus, Boolean vendorsConsentStatus, Boolean vendorsLIStatus)

        Set the user status globally

        Parameters:
        purposesConsentStatus - true if purposes on a consent basis should be enabled, false if they should be disabled
        purposesLIStatus - true if purposes on a legitimate interest basis should be enabled, false if they should be disabled
        vendorsConsentStatus - true if vendors on a consent basis should be enabled, false if they should be disabled
        vendorsLIStatus - true if vendors on a legitimate interest basis should be enabled, false if they should be disabled
      • setUserConsentStatusFromObjects

        @Deprecated(message = "Use {@link #setUserStatusFromObjects(Set, Set, Set, Set, Set, Set, Set, Set)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUserStatusFromObjects(enabledPurposes, disabledPurposes, enabledLegitimatePurposes, disabledLegitimatePurposes, enabledVendors, disabledVendors, enabledLegIntVendors, disabledLegIntVendors")) final Boolean setUserConsentStatusFromObjects(Set<Purpose> enabledPurposes, Set<Purpose> disabledPurposes, Set<Purpose> enabledLegitimatePurposes, Set<Purpose> disabledLegitimatePurposes, Set<Vendor> enabledVendors, Set<Vendor> disabledVendors, Set<Vendor> enabledLegIntVendors, Set<Vendor> disabledLegIntVendors)
      • reset

         final Unit reset()

        Remove all consents and user information from the SDK. If SDK is not ready, the reset will be performed during initialization.

      • onReady

         final Unit onReady(DidomiCallable callback)

        Provide a function that needs to be called once the SDK is ready Automatically call the function if the SDK is already ready (that's why this is not a standard event)

        Parameters:
        callback - that is called once the SDK is ready.
      • onError

         final Unit onError(DidomiCallable callback)

        Provide a function that needs to be called if the SDK encounters an error during initialization. In this case, the SDK will never be ready and onReady will not be called. Automatically call the function if the SDK initialization has already failed

        Parameters:
        callback - that is called if the SDK encounters an error
      • setupUI

         final Unit setupUI(FragmentActivity activity)

        Show the consent notice if required (ie if consent information is missing)

        This does not show the consent notice if all consent information is already available as consent was previously collected.

        This method should be called in the onCreate function of your main activity or in activities where you want the consent notice to be shown to the user. This should be called at least once on every app launch and should cover every path by which the user launches the app (including deep linking) to ensure that consent is collected as often as possible.

      • forceShowNotice

         final Unit forceShowNotice(FragmentActivity activity)

        Force show the consent notice without checking if consent is required

        Parameters:
        activity - base activity to use for notice
      • showNotice

         final Unit showNotice(FragmentActivity activity)

        Show the consent notice (if required, not disabled in the config and not already displayed)

        Parameters:
        activity - base activity to use for notice
      • hideNotice

         final Unit hideNotice()

        Hide the notice if it is currently displayed

      • showPreferences

        @JvmOverloads() final Unit showPreferences(FragmentActivity activity, String view)

        Method used to show the preferences view, by previously updating the fragment manager property based on an activity. It also specifies which view (vendors or purposes) opens first.

        Parameters:
        activity - activity used to get the support fragment manager.
        view - view to show to the user (purposes or vendors).
      • showPreferences

        @JvmOverloads() final Unit showPreferences(FragmentActivity activity)

        Method used to show the preferences view, by previously updating the fragment manager property based on an activity. It also specifies which view (vendors or purposes) opens first.

        Parameters:
        activity - activity used to get the support fragment manager.
      • updateSelectedLanguage

         final Unit updateSelectedLanguage(String languageCode)

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

        Parameters:
        languageCode -
        • international short code (Coded2) for selected language.

      • getText

         final Map<String, String> getText(String key)

        Method used to get a dictionary/map for a given key in the form of { en: "Value in English", fr: "Value in French" } from the didomi_config.json file containing translations in different languages.

        The keys and values considered come from different places in the didomi_config.json file such as { notice: ... }, { preferences: ... } and { texts: ... }, giving the latter the highest priority in case of duplicates.

        Parameters:
        key - string used as a key to find a dictionary/map that contains translation texts.
      • getTranslatedText

         final String getTranslatedText(String key)

        Method used to get a translated string for a given key from the didomi_config.json file based on the currently selected language.

        The keys and values considered come from different places in the didomi_config.json file such as { notice: ... }, { preferences: ... } and { texts: ... }, giving the latter the highest priority in case of duplicates.

        Parameters:
        key - string used as a key to find a translated string.
      • getJavaScriptForWebView

        @JvmOverloads() final String getJavaScriptForWebView(String extra)

        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.

        See https://developers.didomi.io/cmp/mobile-sdk/share-consent-with-webviews for more information.

        Parameters:
        extra - Extra JavaScript to inject in the returned tag (or null)
      • getJavaScriptForWebView

        @JvmOverloads() final String 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.

        See https://developers.didomi.io/cmp/mobile-sdk/share-consent-with-webviews for more information.

      • setUser

        @Deprecated(message = "Use {@link #setUser(UserAuthParams)} instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(UserAuthWithHashParams(id = organizationUserId, algorithm = organizationUserIdAuthAlgorithm, secretId = organizationUserIdAuthSid, digest = organizationUserIdAuthDigest, salt = organizationUserIdAuthSalt, expiration = null))")) final Unit setUser(String organizationUserId, String organizationUserIdAuthAlgorithm, String organizationUserIdAuthSid, String organizationUserIdAuthSalt, String organizationUserIdAuthDigest)

        Set user information with authentication

        Parameters:
        organizationUserId - Organization user ID
        organizationUserIdAuthAlgorithm - Algorithm used for computing the digest
        organizationUserIdAuthSid - ID of the secret used for computing the digest
        organizationUserIdAuthSalt - Salt used for computing the digest (optional)
        organizationUserIdAuthDigest - Digest of the organization user ID and secret
      • setUser

        @JvmOverloads() final Unit setUser(String organizationUserId, FragmentActivity activity)

        Set user information

        Parameters:
        organizationUserId - Organization user ID
        activity - Current activity, so notice is displayed if it is needed after synchronization
      • setUser

        @JvmOverloads() final Unit setUser(String organizationUserId)

        Set user information

        Parameters:
        organizationUserId - Organization user ID
      • setUser

        @JvmOverloads() final Unit setUser(UserAuthParams userAuthParams, FragmentActivity activity)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
        activity - Current activity, so notice is displayed if it is needed after synchronization
      • clearUser

         final Unit clearUser()

        Remove organization user information and reset user id

      • sync

         final Boolean sync(Boolean blocking, FragmentActivity activity)

        Sync the user information with the remote status

        Parameters:
        blocking - Whether the sync process should block the thread or not.
        activity - Current activity, so we can call setupUI when synchronization is done
      • syncIfRequired

         final Unit syncIfRequired(FragmentActivity activity)

        Refresh the user status from the backend if the SDK is ready