Usercentrics - PUBLIC

How do I pass consents from my In-App implementation to a Webview

You can do this by using the WebView User Session Continuity functionality. This is performed by getting the app user data with getUserSessionData() and then passing it on to the webview by injecting it into a global variable called UC_UI_USER_SESSION_DATA in your WKWebView as follows:

let sessionData = usercentrics.getUserSessionData() let script = """ window.UC_UI_USER_SESSION_DATA = \(sessionData); """ let userScript = WKUserScript(source: script, injectionTime: .atDocumentStart, forMainFrameOnly: true) let contentController = WKUserContentController() contentController.addUserScript(userScript) let preferences = WKPreferences() preferences.javaScriptEnabled = true let webConfiguration = WKWebViewConfiguration() webConfiguration.preferences = preferences webConfiguration.userContentController = contentController webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.uiDelegate = self let myURL = URL(string:"https://<some_url>") let myRequest = URLRequest(url: myURL!) webView.load(myRequest)

In order for this to work, you need to be using the In-app SDK in your native app (Android or iOS) and to have the Browser SDK/UI installed on the webpage you will be serving on the webview.

Usercentrics - PUBLIC