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
    • 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
  • Create a consent token and an authenticated URL in your app backend
  • Firebase
  • Launch a Preference Center
  1. API
  2. Widgets
  3. Privacy widgets
  4. Tutorial

Launch a Preference Center from a mobile app

How to launch a Preference Center from a mobile app

PreviousTutorialNextCompliance Reports

Last updated 1 year ago

When launching a Preference Center from a mobile app, the user is taken from your app to the Preference Center running in WebView. While the user is authenticated in your mobile app, this authentication gets lost when the Preference Center is loaded.

To launch a Preference Center from a mobile app and pass the user authentication information, you will need to:

  • Create a consent token for your Preference Center in your app backend

  • Launch your preference center in a WebView

Create a consent token and an authenticated URL in your app backend

A consent token is generated by sending an API request to the Didomi API that includes the user information (in particular, the organization user ID).

To create a consent token, send an HTTP POST request to the Didomi API:

POST https://api.didomi.io/consents/tokens?organization_id=<ID of your organization>
{
    "organization_id": "<ID of your organization>",
    "organization_user_id": "<User ID>",
    "lifetime": 3600
}

Read more about and .

As the private API key must remain private, your app must first call you app backend in an authenticated context and your app backend can then call the Didomi API:

Once you have obtained a consent token, you can generate an authenticated URL to the Preference Center by adding the consent token to the Preference Center URL in a token query-string parameter.

We recommend that your backend returns the full authenticated URL with the token so that your app can simply launch that URL and does not hardcode any part of the URL.

Firebase

The createPreferenceCenterURL Cloud Function will return the authenticated Preference Center URL with the user email from Firebase Authentication. It requires users to be authenticated via Firebase Authentication.

private Task<String> getPreferenceCenterURL() {
    return mFunctions
            .getHttpsCallable("createPreferenceCenterURL")
            .call()
            .continueWith(new Continuation<HttpsCallableResult, String>() {
                @Override
                public String then(@NonNull Task<HttpsCallableResult> task) throws Exception {
                    // This continuation runs on either success or failure, but if the task
                    // has failed then getResult() will throw an Exception which will be
                    // propagated down.
                    String preferenceCenterURL = (String) task.getResult().getData();
                    return preferenceCenterURL;
                }
            });
}
private fun getPreferenceCenterURL(): Task<String> {
    return functions
            .getHttpsCallable("createPreferenceCenterURL")
            .call()
            .continueWith { task ->
                // This continuation runs on either success or failure, but if the task
                // has failed then result will throw an Exception which will be
                // propagated down.
                val preferenceCenterURL = task.result?.data as String
                preferenceCenterURL
            }
}
functions.httpsCallable("createPreferenceCenterURL").call() { (result, error) in
  if let error = error as NSError? {
    if error.domain == FunctionsErrorDomain {
      let code = FunctionsErrorCode(rawValue: error.code)
      let message = error.localizedDescription
      let details = error.userInfo[FunctionsErrorDetailsKey]
    }
    // ...
  }
  if let text = (result?.data as? [String: Any])?["text"] as? String {
    self.resultField.text = text
  }
}

Launch a Preference Center

Once you have obtained an authenticated URL to the Preference Center, simply open it in a WebView or in the device browser.

import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Click handler to call when the user clicks on the menu item/link
 * that should open the Preference Center
 *
 * We assume that you have a WebView created with ID preferenceCenterWebView
 * and the correct Internet permissions as per https://developer.android.com/guide/webapps/webview.html
 */
public void preferenceCenterClickHandler(View view) {
    String preferenceCenterURL = ...; // Get the Preference Center URL as described above
    WebView preferenceCenterWebView = (WebView) findViewById(R.id.preferenceCenterWebView);

    // Ensure that the user stays in the WebView when he navigates
    preferenceCenterWebView.setWebViewClient(new WebViewClient());

    // Enable JavaScript
    preferenceCenterWebView.getSettings().setJavaScriptEnabled(true);

    // Load the URL
    preferenceCenterWebView.loadUrl(preferenceCenterURL);

    // TODO: Actually show the WebView here
}
import android.content.Intent;
import android.net.Uri;
import android.view.View;

/**
 * Click handler to call when the user clicks on the menu item/link
 * that should open the Preference Center
 */
public void privacyCenterClickHandler(View view) {
    String preferenceCenterURL = ...; // Get the Preference Center URL as described above
    Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(preferenceCenterURL));
    startActivity(launchBrowser);
}

Example:

If your app is using Firebase, you can easily create an authenticated URL via a . We provide a Cloud Function to create a Preference Center URL that can be deployed to your Firebase account:

You then can with:

https://privacy.company.com/?token={id_token}
Cloud Function
https://github.com/didomi/firebase
call the Firebase function from your app
authenticating with the Didomi API
creating a consent token