Package io.didomi.sdk

Class Didomi

  • All Implemented Interfaces:

    
    public final class Didomi
    
                        
    • Constructor Detail

    • Method Detail

      • isReady

         final Boolean isReady()

        Is the SDK ready?

        Returns:

        true if sdk initialization is complete

      • isError

         final Boolean isError()

        Has an error occurred during SDK initialization.

        Returns:

        true if initialization failed

      • isInitialized

         final Boolean isInitialized()

        Was the SDK initialized?

        Returns:

        true if the initialize function has been called even if the initialization is not complete (that would be ready).

      • getCurrentUserStatus

         final CurrentUserStatus getCurrentUserStatus(UserAuth userAuth)

        Get the current user status TODO('Revert visibility')

        Parameters:
        userAuth - as UserAuth the user authentication parameters
        Returns:

        the current user status as CurrentUserStatus for the selected user or null if no cached data available

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

         final Boolean shouldUserStatusBeCollected()

        Determine if the User Status (consent) should be collected or not. User Status should be collected if:

        • Regulation is different from NONE and

        • User status is partial and

        • The number of days before displaying the notice again has exceeded the limit specified on the Console or no User Status has been saved

        Returns:

        true if User Status (consent) should be collected

      • shouldConsentBeCollected

        @Deprecated(message = "Use shouldUserStatusBeCollected instead", replaceWith = @ReplaceWith(imports = {}, expression = "shouldUserStatusBeCollected()")) 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

        Returns:

        true if consent should be collected

        Since:

        Deprecated since version 1.88.0

      • setUserAgreeToAll

         final Boolean setUserAgreeToAll()

        Enable all purposes and vendors for the user.

        Returns:

        true if user consent status was updated, false otherwise.

      • setUserDisagreeToAll

         final Boolean setUserDisagreeToAll()

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

        Returns:

        true if user status was updated, false otherwise.

      • 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
        Returns:

        true if user consent status was updated, false otherwise.

      • openCurrentUserTransaction

        @Deprecated(message = "Use openCurrentUserStatusTransaction instead", replaceWith = @ReplaceWith(imports = {}, expression = "openCurrentUserStatusTransaction()")) final CurrentUserStatusTransaction openCurrentUserTransaction()
      • openCurrentUserStatusTransaction

         final CurrentUserStatusTransaction openCurrentUserStatusTransaction()

        Open a CurrentUserStatusTransaction to modify the user status

      • 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

      • isNoticeVisible

         final Boolean isNoticeVisible()

        Check if the consent notice is currently displayed

        Returns:

        true if ConsentNoticeBottomFragment or ConsentNoticePopupFragment exists

      • 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.
        Returns:

        a dictionary/map that contains the translation texts in different languages for the given key.

      • 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.
        Returns:

        a translated string based on the provided key and the selected language.

      • 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 setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(UserAuthWithoutParams(organizationUserId), activity, isUnderage))"))@JvmOverloads() final Unit setUser(String organizationUserId, FragmentActivity activity, Boolean isUnderage)

        Set user information

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

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(UserAuthWithoutParams(organizationUserId), activity, isUnderage))"))@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

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(UserAuthWithoutParams(organizationUserId), activity, isUnderage))"))@JvmOverloads() final Unit setUser(String organizationUserId)

        Set user information

        Parameters:
        organizationUserId - Organization user ID
      • setUser

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(userAuthParams, dcsUser, activity, isUnderage))"))@JvmOverloads() final Unit setUser(UserAuthParams userAuthParams, List<UserAuthParams> synchronizedUsers, FragmentActivity activity, Boolean isUnderage, UserAuthParams dcsUser)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
        synchronizedUsers - Additional users to synchronize, should be null in most cases
        activity - Current activity, so notice is displayed if it is needed after synchronization
        isUnderage - Whether the user is underage
        dcsUser - User authentication parameters used for DCS signature
      • setUser

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(userAuthParams, dcsUser, activity, isUnderage))"))@JvmOverloads() final Unit setUser(UserAuthParams userAuthParams, List<UserAuthParams> synchronizedUsers, FragmentActivity activity, Boolean isUnderage)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
        synchronizedUsers - Additional users to synchronize, should be null in most cases
        activity - Current activity, so notice is displayed if it is needed after synchronization
        isUnderage - Whether the user is underage
      • setUser

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(userAuthParams, dcsUser, activity, isUnderage))"))@JvmOverloads() final Unit setUser(UserAuthParams userAuthParams, List<UserAuthParams> synchronizedUsers, FragmentActivity activity)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
        synchronizedUsers - Additional users to synchronize, should be null in most cases
        activity - Current activity, so notice is displayed if it is needed after synchronization
      • setUser

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(userAuthParams, dcsUser, activity, isUnderage))"))@JvmOverloads() final Unit setUser(UserAuthParams userAuthParams, List<UserAuthParams> synchronizedUsers)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
        synchronizedUsers - Additional users to synchronize, should be null in most cases
      • setUser

        @Deprecated(message = "Use setUser with DidomiUserParameters instead", replaceWith = @ReplaceWith(imports = {}, expression = "setUser(DidomiUserParameters(userAuthParams, dcsUser, activity, isUnderage))"))@JvmOverloads() final Unit setUser(UserAuthParams userAuthParams)

        Set user information with authentication

        Parameters:
        userAuthParams - User authentication parameters
      • clearUser

         final Unit clearUser()

        Remove organization user information and reset user id

      • setLocalProperty

         final Unit setLocalProperty(String key, Object value)

        Internal use only. Can activate specific features currently in development.

        Parameters:
        key - the key of the property
        value - the value of the property
      • getInstance

         final static Didomi getInstance()

        Get Didomi instance.

        Returns:

        current instance or newly created instance of Didomi