---
title: Consent sharing with WebView (App)
slug: pubtech-cmp/consent-sharing-with-webview-app
docTags: 
createdAt: 2025-01-17T14:05:22.349Z
---

This guide explains how to use the consent-sharing functionality through the APIs provided in the Android and iOS SDKs.

The implementation allows synchronization of consent data between your application and a WebView via a JavaScript script.

The APIs described below are available starting from version v3.X.X of the Android and iOS SDKs.

### Android

In the Android SDK, consent can be managed using the \`cmp\` object and the \`onConsentReady\` method. Once the consent API is ready, a \`consentApiInterface\` is provided, which can be used to obtain the necessary JavaScript to pass as a parameter to the WebView's \`evaluateJavascript\`. Below is an example:


```kotlin
cmpInstance.onConsentReady { consentApiInterface ->
    webView.evaluateJavascript(consentApiInterface.getJavaScriptForWebView()) { s ->
    }
}kot
```

### iOS

In the iOS SDK, consent is managed through PubConsentCMP.shared. Once the consent API is ready, a consentApiInterface is provided, which can be used to obtain the necessary JavaScript to pass as a parameter to the WebView's evaluateJavascript.

:::BlockQuote
PubConsentCMP.shared.onConsentReady \{ consentApiInterface in
&#x20;   webView\.evaluateJavaScript(consentApiInterface.getJavaScriptForWebView()) \{ (result, error) in
&#x20;   }
}
:::

### The CMP still display

Since delays might occur, you can prevent the CMP from appearing in your WebView by adding the following query string to the URL:
` ?pubconsent.waitForExternalConsent=1`

This will block the CMP from appearing in the WebView. Instead, the CMP in the WebView will wait for the consent to be shared using the APIs described above.

