Package io.didomi.sdk

Class Didomi


  • public class Didomi
    extends java.lang.Object
    Main class exposed to apps
    • Field Detail

      • apiEventsRepository

        @Inject
        protected io.didomi.sdk.apiEvents.ApiEventsRepository apiEventsRepository
      • connectivityHelper

        @Inject
        protected io.didomi.sdk.remote.ConnectivityHelper connectivityHelper
      • consentRepository

        @Inject
        protected io.didomi.sdk.consent.ConsentRepository consentRepository
      • contextHelper

        @Inject
        protected io.didomi.sdk.ContextHelper contextHelper
      • countryHelper

        @Inject
        protected io.didomi.sdk.location.CountryHelper countryHelper
      • didomiInitializeParameters

        @Inject
        protected io.didomi.sdk.DidomiInitializeParameters didomiInitializeParameters
      • languagesHelper

        @Inject
        protected io.didomi.sdk.resources.LanguagesHelper languagesHelper
      • remoteFilesHelper

        @Inject
        protected io.didomi.sdk.remote.RemoteFilesHelper remoteFilesHelper
      • resourcesHelper

        @Inject
        protected io.didomi.sdk.resources.ResourcesHelper resourcesHelper
      • sharedPreferences

        @Inject
        protected android.content.SharedPreferences sharedPreferences
      • syncRepository

        @Inject
        @Nullable
        protected io.didomi.sdk.user.sync.SyncRepository syncRepository
      • tcfRepository

        @Inject
        protected io.didomi.sdk.tcf.TCFRepository tcfRepository
      • uiStateRepository

        @Inject
        protected io.didomi.sdk.ui.UIStateRepository uiStateRepository
      • uiProvider

        @Inject
        protected io.didomi.sdk.ui.UIProvider uiProvider
      • userChoicesInfoProvider

        @Inject
        protected io.didomi.sdk.utils.UserChoicesInfoProvider userChoicesInfoProvider
      • userStatusRepository

        @Inject
        protected io.didomi.sdk.UserStatusRepository userStatusRepository
      • userRepository

        @Inject
        protected io.didomi.sdk.user.UserRepository userRepository
    • Method Detail

      • getInstance

        public static Didomi getInstance()
        Get the global singleton instance of the Didomi SDK.
        Returns:
        Didomi
      • clearInstance

        public static void clearInstance()
        Internal use only. Clear the Didomi instance so it is possible to initialize it again.
      • setLogLevel

        public void setLogLevel​(int 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
      • getLogoResourceId

        public int getLogoResourceId()
        Get the logo resource id
        Returns:
        the resource id of the logo defined in application configuration, or 0 if logo was not defined or does not correspond to an image in the project resources
      • getEventsRepository

        public io.didomi.sdk.events.EventsRepository getEventsRepository()
                                                                  throws DidomiNotReadyException
        Getter method for eventsRepository.
        Returns:
        instance of EventsRepository.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getOrganizationUserRepository

        public io.didomi.sdk.user.OrganizationUserRepository getOrganizationUserRepository()
        Getter method for organizationUserRepository
        Returns:
        an instance of OrganizationUserRepository
      • initialize

        @Deprecated
        public void initialize​(android.app.Application application,
                               java.lang.String apiKey,
                               @Nullable
                               java.lang.String localConfigurationPath,
                               @Nullable
                               java.lang.String remoteConfigurationUrl,
                               @Nullable
                               java.lang.String providerId,
                               java.lang.Boolean disableDidomiRemoteConfig,
                               java.lang.String languageCode)
                        throws java.lang.Exception
        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. If not specified, by defalut is set as didomi_config.json in the app assets.
        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. By default, the consent UI is displayed in the language configured in the device settings, if langauge is availabe and enabled by your configuration. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code e.g.: "es", "fr", etc.
        Throws:
        java.lang.Exception
        Since:
        Deprecated since version 1.42.0
      • initialize

        @Deprecated
        public void initialize​(android.app.Application application,
                               java.lang.String apiKey,
                               @Nullable
                               java.lang.String localConfigurationPath,
                               @Nullable
                               java.lang.String remoteConfigurationUrl,
                               @Nullable
                               java.lang.String providerId,
                               java.lang.Boolean disableDidomiRemoteConfig,
                               java.lang.String languageCode,
                               java.lang.String noticeId)
                        throws java.lang.Exception
        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. By default set as didomi_config.json in the app assets.
        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. By default, the consent UI is displayed in the language configured in the device settings, if language is available and enabled by your configuration. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code e.g.: "es", "fr", etc.
        noticeId - ID of the notice configuration to load if your are not using app ID targeting
        Throws:
        java.lang.Exception
        Since:
        Deprecated since version 1.42.0
      • initialize

        public void initialize​(android.app.Application application,
                               io.didomi.sdk.DidomiInitializeParameters parameters)
                        throws java.lang.Exception
        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.
        Throws:
        java.lang.Exception
      • initialize

        @Deprecated
        public void initialize​(android.app.Application application,
                               java.lang.String apiKey,
                               @Nullable
                               java.lang.String localConfigurationPath,
                               @Nullable
                               java.lang.String remoteConfigurationURL,
                               @Nullable
                               java.lang.String providerId,
                               java.lang.Boolean disableDidomiRemoteConfig)
                        throws java.lang.Exception
        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. If not specified, by defalut is set as didomi_config.json in the app assets.
        remoteConfigurationURL - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
        disableDidomiRemoteConfig - Used to disable remote configuration.
        Throws:
        java.lang.Exception
        Since:
        Deprecated since version 1.42.0
      • initialize

        @Deprecated
        public void initialize​(android.app.Application application,
                               java.lang.String apiKey,
                               @Nullable
                               java.lang.String localConfigurationPath,
                               @Nullable
                               java.lang.String remoteConfigurationURL,
                               @Nullable
                               java.lang.String providerId)
                        throws java.lang.Exception
        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. If not specified, by defalut is set as didomi_config.json in the app assets.
        remoteConfigurationURL - URL to client specific remote config file in JSON format.
        providerId - Your provider ID (if any).
        Throws:
        java.lang.Exception
        Since:
        Deprecated since version 1.42.0
      • getLanguagesHelper

        public io.didomi.sdk.resources.LanguagesHelper getLanguagesHelper()
                                                                   throws DidomiNotReadyException
        Method used to get the language helper.
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getResourcesHelper

        public io.didomi.sdk.resources.ResourcesHelper getResourcesHelper()
                                                                   throws DidomiNotReadyException
        Retrieve ResourcesHelper used to handle device resources
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getUiStateRepository

        public io.didomi.sdk.ui.UIStateRepository getUiStateRepository()
                                                                throws DidomiNotReadyException
        Internal use only. Used to handle some UI state parameters.
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isConsentRequired

        public boolean isConsentRequired()
                                  throws DidomiNotReadyException
        Determine if consent is required for the user. The rules are (OR): - The user country is in the EU - The company is from the EU - The user country is unknown and the app has chosen to collect consent when unknown
        Returns:
        True if consent is required, false if it is not required.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isUserConsentStatusPartial

        public boolean isUserConsentStatusPartial()
                                           throws DidomiNotReadyException
        Determine if consent information is available for all purposes and vendors that are required
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isUserLegitimateInterestStatusPartial

        public boolean isUserLegitimateInterestStatusPartial()
                                                      throws DidomiNotReadyException
        Determine if legitimate interest information is available for all purposes and vendors that are required
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isUserStatusPartial

        public boolean isUserStatusPartial()
                                    throws DidomiNotReadyException
        Check if consent or legitimate interest status is partial
        Returns:
        **true** if consent or legitimate interest is partial, **false** otherwise
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getUserStatus

        @NonNull
        public io.didomi.sdk.models.UserStatus getUserStatus()
                                                      throws DidomiNotReadyException
        Get the user consent status
        Returns:
        the user consent status as UserStatus
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getUserConsentStatusForVendor

        @Deprecated
        @Nullable
        public java.lang.Boolean getUserConsentStatusForVendor​(java.lang.String vendorId)
                                                        throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the vendorId in getUserStatus().getVendors().getGlobalConsent().getEnabled() or getUserStatus().getVendors().getConsent().getDisabled().
        Get the user consent status for a specific vendor
        Parameters:
        vendorId -
        Returns:
        the user consent status for this vendor
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • getUserLegitimateInterestStatusForVendor

        @Deprecated
        public java.lang.Boolean getUserLegitimateInterestStatusForVendor​(java.lang.String vendorId)
                                                                   throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the vendorId in getUserStatus().getVendors().getGlobalLegitimateInterest().getEnabled() or getUserStatus().getVendors().getLegitimateInterest().getDisabled().
        Get the user legitimate interest status for a specific vendor
        Parameters:
        vendorId -
        Returns:
        the user consent status for this vendor
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • getUserStatusForVendor

        @Deprecated
        public boolean getUserStatusForVendor​(java.lang.String vendorId)
                                       throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the vendorId in getUserStatus().getVendors().getGlobal().getEnabled() or getUserStatus().getVendors().getGlobal().getDisabled().
        Get the user consent and legitimate interest status for a specific vendor
        Parameters:
        vendorId -
        Returns:
        true if both consent and legitimate interest status are enabled by the user, false otherwise
        Throws:
        DidomiNotReadyException
        Since:
        Deprecated since 1.43.1
      • getUserConsentStatusForPurpose

        @Deprecated
        @Nullable
        public java.lang.Boolean getUserConsentStatusForPurpose​(java.lang.String purposeId)
                                                         throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the purposeId in getUserStatus().getPurposes().getConsent().getEnabled() or getUserStatus().getPurposes().getConsent().getDisabled().
        Get the user consent status for a specific purpose
        Parameters:
        purposeId -
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • getUserLegitimateInterestStatusForPurpose

        @Deprecated
        public java.lang.Boolean getUserLegitimateInterestStatusForPurpose​(java.lang.String purposeId)
                                                                    throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the purposeId in getUserStatus().getPurposes().getLegitimateInterest().getEnabled() or getUserStatus().getPurposes().getLegitimateInterest().getDisabled().
        Get the user legitimate interest status for a specific purpose
        Parameters:
        purposeId -
        Returns:
        the user consent status for this purpose
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • getUserConsentStatusForVendorAndRequiredPurposes

        @Deprecated
        public java.lang.Boolean getUserConsentStatusForVendorAndRequiredPurposes​(java.lang.String vendorId)
                                                                           throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getVendors().getGlobalConsent().getEnabled() or getUserStatus().getVendors().getGlobalConsent().getDisabled().
        Check if a vendor has consent for all the purposes that it requires
        Parameters:
        vendorId -
        Returns:
        the user consent status for all the purpose of this vendor
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • getUserLegitimateInterestStatusForVendorAndRequiredPurposes

        @Deprecated
        public boolean getUserLegitimateInterestStatusForVendorAndRequiredPurposes​(java.lang.String vendorId)
                                                                            throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. Search the purposeId in getUserStatus().getVendors().getGlobalLegitimateInterest().getEnabled() or getUserStatus().getVendors().getGlobalLegitimateInterest().getDisabled().
        Check if a vendor has consent for all the legitimate interest purposes that it requires
        Parameters:
        vendorId -
        Returns:
        the user consent status for all the legitimate interest purposes of this vendor
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.43.1
      • setUserAgreeToAll

        public boolean setUserAgreeToAll()
                                  throws DidomiNotReadyException
        Enable all purposes and vendors for the user.
        Returns:
        true if user consent status was updated, false otherwise.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • setUserDisagreeToAll

        public boolean setUserDisagreeToAll()
                                     throws DidomiNotReadyException
        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.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • setUserStatus

        public boolean setUserStatus​(boolean purposesConsentStatus,
                                     boolean purposesLIStatus,
                                     boolean vendorsConsentStatus,
                                     boolean vendorsLIStatus)
                              throws DidomiNotReadyException
        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.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • setUserConsentStatus

        @Deprecated
        public boolean setUserConsentStatus​(java.util.Set<java.lang.String> enabledPurposeIds,
                                            java.util.Set<java.lang.String> disabledPurposeIds,
                                            java.util.Set<java.lang.String> enabledLegitimatePurposeIds,
                                            java.util.Set<java.lang.String> disabledLegitimatePurposeIds,
                                            java.util.Set<java.lang.String> enabledVendorIds,
                                            java.util.Set<java.lang.String> disabledVendorIds,
                                            java.util.Set<java.lang.String> enabledLegIntVendorIds,
                                            java.util.Set<java.lang.String> disabledLegIntVendorIds)
                                     throws DidomiNotReadyException
        Throws:
        DidomiNotReadyException
        Since:
        Deprecated since version 1.31.0
        See Also:
        setUserStatus(Set, Set, Set, Set, Set, Set, Set, Set)
      • setUserStatus

        @Deprecated
        public boolean setUserStatus​(java.util.Set<java.lang.String> enabledConsentPurposeIds,
                                     java.util.Set<java.lang.String> disabledConsentPurposeIds,
                                     java.util.Set<java.lang.String> enabledLIPurposeIds,
                                     java.util.Set<java.lang.String> disabledLIPurposeIds,
                                     java.util.Set<java.lang.String> enabledConsentVendorIds,
                                     java.util.Set<java.lang.String> disabledConsentVendorIds,
                                     java.util.Set<java.lang.String> enabledLIVendorIds,
                                     java.util.Set<java.lang.String> disabledLIVendorIds,
                                     boolean sendAPIEvent)
                              throws DidomiNotReadyException
        Deprecated.
        This internal function should not be used, use setUserStatus(Set, Set, Set, Set, Set, Set, Set, Set) instead
        Throws:
        DidomiNotReadyException
        Since:
        Deprecated since version 1.45.0
        See Also:
        setUserStatus(Set, Set, Set, Set, Set, Set, Set, Set)
      • setUserStatus

        public boolean setUserStatus​(java.util.Set<java.lang.String> enabledConsentPurposeIds,
                                     java.util.Set<java.lang.String> disabledConsentPurposeIds,
                                     java.util.Set<java.lang.String> enabledLIPurposeIds,
                                     java.util.Set<java.lang.String> disabledLIPurposeIds,
                                     java.util.Set<java.lang.String> enabledConsentVendorIds,
                                     java.util.Set<java.lang.String> disabledConsentVendorIds,
                                     java.util.Set<java.lang.String> enabledLIVendorIds,
                                     java.util.Set<java.lang.String> disabledLIVendorIds)
                              throws DidomiNotReadyException
        Set the user status
        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
        Returns:
        true if user consent status was updated, false otherwise.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getConsentRepository

        public io.didomi.sdk.consent.ConsentRepository getConsentRepository()
                                                                     throws DidomiNotReadyException
        Getter method for consentRepository property.
        Returns:
        instance of ConsentRepository.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getCountryHelper

        public io.didomi.sdk.location.CountryHelper getCountryHelper()
                                                              throws DidomiNotReadyException
        Getter method for countryHelper property.
        Returns:
        an instance of CountryHelper.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getContextHelper

        public io.didomi.sdk.ContextHelper getContextHelper()
                                                     throws DidomiNotReadyException
        Getter method for context helper.
        Returns:
        an instance of ContextHelper.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getApiEventsRepository

        public io.didomi.sdk.apiEvents.ApiEventsRepository getApiEventsRepository()
                                                                           throws DidomiNotReadyException
        Getter method for apiEventsRepository property.
        Returns:
        instance of ApiEventsRepository.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getUserRepository

        public io.didomi.sdk.user.UserRepository getUserRepository()
                                                            throws DidomiNotReadyException
        Getter for UserRepository property.
        Returns:
        an instance of UserRepository.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • addEventListener

        public void addEventListener​(io.didomi.sdk.events.EventListener listener)
        Add an event listener
        Parameters:
        listener - the EventListener to add
      • addEventListener

        public void addEventListener​(io.didomi.sdk.functionalinterfaces.DidomiEventListener listener)
        Add an event listener
        Parameters:
        listener - the DidomiEventListener to add
      • removeEventListener

        public void removeEventListener​(io.didomi.sdk.functionalinterfaces.DidomiEventListener listener)
        Remove a previously added event listener
        Parameters:
        listener - the DidomiEventListener to remove
      • setupUI

        public void setupUI​(androidx.fragment.app.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

        public void forceShowNotice​(androidx.fragment.app.FragmentActivity activity)
                             throws DidomiNotReadyException
        Force show the consent notice without checking if consent is required
        Parameters:
        activity - base activity to use for notice
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • showNotice

        public void showNotice​(androidx.fragment.app.FragmentActivity activity)
                        throws DidomiNotReadyException
        Show the consent notice (if required, not disabled in the config and not already displayed)
        Parameters:
        activity - base activity to use for notice
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isNoticeVisible

        public boolean isNoticeVisible()
                                throws DidomiNotReadyException
        Check if the consent notice is currently displayed
        Returns:
        true if ConsentNoticeBottomFragment or ConsentNoticePopupFragment exists
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • shouldConsentBeCollected

        public boolean shouldConsentBeCollected()
                                         throws DidomiNotReadyException
        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
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • showPreferences

        public void showPreferences​(androidx.fragment.app.FragmentActivity activity)
                             throws DidomiNotReadyException
        Show the Preferences dialog on the Purposes view
        Parameters:
        activity - activity used to get the support fragment manager.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • showPreferences

        public void showPreferences​(androidx.fragment.app.FragmentActivity activity,
                                    java.lang.String view)
                             throws DidomiNotReadyException
        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).
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isPreferencesVisible

        public boolean isPreferencesVisible()
                                     throws DidomiNotReadyException
        Check if the Preferences view is currently displayed
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • isReady

        public boolean isReady()
        Is the Didomi SDK ready?
        Returns:
        true if sdk is ready
      • isError

        public boolean isError()
        Has the Didomi SDK encountered an error ?
        Returns:
        true if sdk has error
      • isInitialized

        public boolean isInitialized()
        Is the Didomi SDK initialized? This is set to `true` immediately after the call to `initialize()`. The SDK might not be ready yet so use `isReady()` or `onReady()` instead of this function.
        Returns:
        true if sdk is initialized
      • onReady

        public void onReady​(DidomiCallable callback)
                     throws java.lang.Exception
        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.
        Throws:
        java.lang.Exception
      • onError

        public void onError​(DidomiCallable callback)
                     throws java.lang.Exception
        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
        Throws:
        java.lang.Exception
      • getRequiredPurposeIds

        public java.util.Set<java.lang.String> getRequiredPurposeIds()
                                                              throws DidomiNotReadyException
        Get the configured purpose IDs
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getRequiredVendorIds

        public java.util.Set<java.lang.String> getRequiredVendorIds()
                                                             throws DidomiNotReadyException
        Get the configured vendor IDs
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getEnabledPurposes

        @Deprecated
        public java.util.Set<Purpose> getEnabledPurposes()
                                                  throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getPurposes().getGlobal().getEnabled().
        Get the enabled purposes
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getEnabledPurposeIds

        @Deprecated
        public java.util.Set<java.lang.String> getEnabledPurposeIds()
                                                             throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getPurposes().getGlobal().getEnabled().
        Get the IDs of the enabled purposes
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getDisabledPurposes

        @Deprecated
        public java.util.Set<Purpose> getDisabledPurposes()
                                                   throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
        Get the disabled purposes
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getDisabledPurposeIds

        @Deprecated
        public java.util.Set<java.lang.String> getDisabledPurposeIds()
                                                              throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
        Get the IDs of the disabled purposes
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getEnabledVendors

        @Deprecated
        public java.util.Set<Vendor> getEnabledVendors()
                                                throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
        Get the enabled vendors
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getEnabledVendorIds

        @Deprecated
        public java.util.Set<java.lang.String> getEnabledVendorIds()
                                                            throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
        Get the IDs of the enabled vendors
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getDisabledVendors

        @Deprecated
        public java.util.Set<Vendor> getDisabledVendors()
                                                 throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
        Get the disabled vendors
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getDisabledVendorIds

        @Deprecated
        public java.util.Set<java.lang.String> getDisabledVendorIds()
                                                             throws DidomiNotReadyException
        Deprecated.
        use getUserStatus() instead. The result of this method has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
        Get the IDs of the disabled vendors
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
        Since:
        Deprecated since 1.42.0
      • getVendor

        public Vendor getVendor​(java.lang.String vendorId)
                         throws DidomiNotReadyException
        Get a vendor from its ID
        Parameters:
        vendorId -
        Returns:
        the Vendor matching the id
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getJavaScriptForWebView

        public java.lang.String getJavaScriptForWebView​(java.lang.String extra)
                                                 throws DidomiNotReadyException
        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
        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getQueryStringForWebView

        public java.lang.String getQueryStringForWebView()
                                                  throws DidomiNotReadyException
        Get a query-string to add to the URL of a WebView or Chrome Custom Tab to pass the consent status from the app to the Didomi Web SDK embedded on the target URL.

        The returned parameter will have the format `didomiConfig.user.externalConsent.value=...`. It includes the user consent information URL-encoded and JSON-encoded. Append the returned query-string parameter to the URL of your WebView or Chrome Custom Tab.

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

        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getJavaScriptForWebView

        public java.lang.String getJavaScriptForWebView()
                                                 throws DidomiNotReadyException
        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`

        Returns:
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getDeviceType

        public io.didomi.sdk.DeviceType getDeviceType()
                                               throws DidomiNotReadyException
        Get the device type determined by Didomi SDK
        Returns:
        the device for which Didomi will display UI
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • updateSelectedLanguage

        public void updateSelectedLanguage​(java.lang.String languageCode)
                                    throws DidomiNotReadyException
        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.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getText

        public java.util.Map<java.lang.String,​java.lang.String> getText​(java.lang.String key)
                                                                       throws DidomiNotReadyException
        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.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • getTranslatedText

        public java.lang.String getTranslatedText​(java.lang.String key)
                                           throws DidomiNotReadyException
        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.
        Throws:
        DidomiNotReadyException - exception thrown if this method is called before the Didomi SDK is ready.
      • setUserAgent

        public void setUserAgent​(@NonNull
                                 java.lang.String name,
                                 @NonNull
                                 java.lang.String version)
        Set custom user agent name and version
        Parameters:
        name -
        version -
      • setUser

        public void setUser​(java.lang.String organizationUserId)
        Set user information
        Parameters:
        organizationUserId - Organization user ID
      • setUser

        @Deprecated
        public void setUser​(java.lang.String organizationUserId,
                            @NonNull
                            java.lang.String organizationUserIdAuthAlgorithm,
                            @NonNull
                            java.lang.String organizationUserIdAuthSid,
                            @Nullable
                            java.lang.String organizationUserIdAuthSalt,
                            @NonNull
                            java.lang.String organizationUserIdAuthDigest)
        Deprecated.
        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
        Since:
        Deprecated since version 1.43.0
      • setUser

        public void setUser​(@NonNull
                            io.didomi.sdk.user.UserAuthParams userAuthParams)
        Set user information with authentication
        Parameters:
        userAuthParams - User authentication parameters
      • hasAnyStatus

        public boolean hasAnyStatus()
        Check if we have collected any status (consent or legitimate interest) from the user
        Returns:
        True if the user has at least one status, positive of negative