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

Share consent with WebViews

PreviousShare consents across devicesNextGoogle Consent Mode v2

Last updated 1 year ago

If your mobile app sometimes opens WebViews or Chrome Custom Tabs to display specific content to the user, you should ensure that consent is passed from your app to the website loaded in the WebView or Chrome Custom Tab. That will ensure that the user does not have to give consent again in WebViews or Chrome Custom Tabs.

The setup is the following:

  • Collect consent in your app with the Didomi native SDKs

  • Launch a WebView or a Chrome Custom Tab with the Didomi Web SDK embedded in it

  • Inject JavaScript into the WebView to pass consent information from the native app

This guide assumes that you have already setup the Didomi native SDKs in your Android or iOS app, and that you have setup our Web SDK in the HTML pages loaded into your WebViews or Chrome Custom Tabs.

SDK requirements The minimum SDK versions that support passing TCF v2 consent to a WebView are 1.26.1 (Android) and 1.38.0 (iOS).

The minimum SDK version that supports passing consent to a Chrome Custom Tab is 1.17.0 (Android).

If your app is a web application embedded through a WebView or a PWA, we recommend rather than our native mobile SDKs.

Web SDK configuration in the WebView or Chrome Custom Tab

You need to embed the Didomi Web SDK in the HTML page that is loaded by the WebView or the Chrome Custom Tab so that it can collect the consent information passed from the app and share it with vendors.

The list of vendors configured in the web SDK in the WebView should be a subset of the list of vendors configured in the mobile app. That will ensure that the WebView has all the consent information it needs and does not re-collect consent. Examples:

Configuration
WebView behavior

Vendors in the mobile app and the WebView are the same

WebView will not display the consent UI and will use the consent information provided by the mobile app as is

Vendors in the WebView are a subset of the vendors in the mobile app

WebView will not display the consent UI and will use the consent information provided by the mobile app as is

Vendors in the mobile app are a subset of the vendors in the WebView, or there is no vendor in common

WebView will display the consent UI and collect user consent for the vendors that are specific to the WebView

Other parameters of the web SDK can be configured freely, in particular with respect to the IAB framework and tags management.

Inject consent information into the WebView or Chrome Custom Tab

Passing consent to a WebView or to a Chrome Custom Tab is a slightly different operation. Read below for specific instructions based on the method you are using.

WebViews (Android and iOS)

The consent status can be passed to the Web SDK by embedding JavaScript code into your WebView.

On Android, make sure JavaScript is enabled on the WebView. In some configurations (for example, when using a custom domain), enabling DOM storage is also necessary.

The Android and iOS SDKs automatically generate the required JavaScript code for you with the getJavaScriptForWebView method. Call that method and embed the returned string into your WebView:

webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true

val didomi = Didomi.getInstance()
didomi.onReady {
    val didomiJavaScriptCode = didomi.getJavaScriptForWebView()
    webView.evaluateJavascript(didomiJavaScriptCode) { s ->
    }
}
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);

final Didomi didomi = Didomi.getInstance();
didomi.onReady(() -> {
    String didomiJavaScriptCode = didomi.getJavaScriptForWebView();
    webView.evaluateJavascript(didomiJavaScriptCode, s -> {
    });
});
Didomi.shared.onReady {
    let didomiJavaScriptCode = Didomi.shared.getJavaScriptForWebView()
    webView.evaluateJavaScript(didomiJavaScriptCode, completionHandler: nil)
}

Chrome Custom Tabs (Android only)

Android SDK

As Chrome Custom Tabs do not allow embedding JavaScript into a web page, the consent status of the user can be passed to the Web SDK by appending a query string parameter to the URL loaded by the Chrome Custom Tab. That query string parameter will contain the current status of the user and will be read by the Web SDK.

val didomi = Didomi.getInstance()
didomi.onReady {
    val didomiQueryString = didomi.queryStringForWebView
    val url = "https://www.website.com/?$didomiQueryString"
}
final Didomi didomi = Didomi.getInstance();
didomi.onReady(() -> {
    String didomiQueryString = didomi.getQueryStringForWebView();
    String url = "https://www.website.com/?" + didomiQueryString;
});

Example of a full URL: https://www.website.com/?didomiConfig.user.externalConsent.value=...

Web SDK

The Web SDK needs to be configured to read the user consent from the query string as that behavior is disabled by default. To do so, update your custom JSON or your local didomiConfig with:

{
  user: {
    externalConsent: {
      enabled: true
    }
  }
}

Hide the notice in the WebView or Chrome Custom Tab

The notice should automatically get hidden in the WebView as consent is passed from the mobile app to the website. However, it might happen that the notice gets displayed for a very short time before being hidden.

To avoid that visual glitch, you can disable the notice in your WebView or Chrome Custom Tab to make sure that it never shows by appending didomiConfig.notice.enable=false to the query string of the URL that you are loading:

{{YOUR_WEBSITE_URL}}?didomiConfig.notice.enable=false

If the notice still shows in the WebView or Chrome Custom Tab when navigating to another page, ensure that the list of vendors and purposes is the same between the mobile app and the website that is loaded in the WebView or Chrome Custom Tab.

The method returns a query string parameter with the format didomiConfig.user.externalConsent.value=.... It can be appended to your URL after a ? or a & if your URL already contains a query string.

using our Web SDK
getQueryStringForWebView