Enable Authenticated Consent

Authenticated consent allows your organization to tie an end-users consent preferences to a unique end-user identifier that will persist across authenticated (i.e. logged-in) devices. In this article, we will cover how to enable authenticated consent for:

Requirements

The following requirements must be met In order to successfully utilize authenticated consent between web and app properties:

  • Properties using authenticated consent must use the same vendor list

  • The consent scope for the vendor list should be set to Shared site (see below)

Web

To implement authenticated consent on a web page, you can write a cookie directly on the page to pass the consent identifier to Sourcepoint.

document.cookie = "authId=123123123";

iOS Devices

To implement authenticated consent on iOS devices, the authId should be passed as a parameter when the .loadMessage() function is initially called in our first class SDK for iOS.

//Example for Swift
consentViewController.loadMessage(forAuthId: "JohnDoe")
//Example for Objective-C
[consentViewController loadMessage for AuthId: @"JohnDoe"]

Android Devices

To implement authenticated consent on android devices, you will need to use the .setauthId(string) function in the context of the consentLib object when you run a new build.

//Example only. Your parameters should correspond to your property
ConsentLib.newBuilder(22, "mobile.demo", 2323, "6d1f92c8d85c4d41d7963412",this)
//calling other .set methods
.setAuthId("JohnDoe")
.build();

The SDK will bring the consent data from the server, overwriting whatever was stored in the device.

Webview

To implement authenticated consent for webviews, create a cookie with the authId as content before the CMP javascript tag is loaded. This can either be done within the webview, or it can also be set when initializing the webview from the native app.

Your organization will need to integrate the CMP javascript tags within your webview prior to enabling authenticated consent.

//iOS example
let cookie = HTTPCookie(properties: [
.domain: "mobile.demo.com",
.path: "/",
.name: "authId",
.value: "JohnDoe",
.seucre: "TRUE:,
.expires: NSDate(timeIntervalSinceNow: 42667037)
])!
webView.configuration.websiteDataStore.httpCookieStore.setCookie(cookie)
//Android example
private fun setCookie(){
val webView = WebView(this) //this = context
val cookieManager = CookieManager.getInstance()
cookieManager.acceptCookie()
val domain = "https://mobile.demo.com/"
webView.webViewClient = WebViewClient()
webView.settings.javaScriptEnabled = true
$cookieKey = "authId";
$cookieValue = "JohnDoe"
cookieManager.setCookie(domain,"$cookieKey=$cookieValue")
cookieManager.setAcceptThirdPartyCookies(webView, true)
webView.loadUrl(domain)
}