Skip to main content

Android TV

Get AppConsent TV SDK

To add the AppConsent SDK to your Android project, follow the steps below :

In your global file, add the following and replace ${username} by the provided username and ${encrypted_password} by the provided encrypted password. Please contact us, if you don't have your ${username} and ${encrypted_password} .


In your project build.gradle file, under allprojects/repositories add the following :

maven {
url ""
credentials {
username = "${appconsent_artifactory_client_username}"
password = "${appconsent_artifactory_client_password}"

In your application build.gradle file, under android add the following :

packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/*.kotlin_module'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

In your application build.gradle add the following

dependencies { 
implementation 'com.sfbx.appconsent:appconsent-tv:${currentTvVersion}'

Where currentTvVersion = 1.1.15


AppConsent uses androidX Jetpack, so it's not compatible with android.supportapplications.

How to use AppConsent

1. Get your AppKey from AppConsent :


2. Create AppConsentTV

import android.os.Bundle

class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
val appConsentTV = AppConsentTV(
context = this,
appKey = "YOUR_APP_KEY",
forceApplyGDPR = true,
theme = AppConsentTVTheme.Builder(this)
.iconDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android))
) {

If forceApplyGDPR is true, it forces CMP to display even if your country isn't subject to GDPR.

Function onReady() is called when AppConsent finished initializing. It can avoid bugs when you want to present notice just after creating AppConsentTV object.

For now, you can only override theme and icon with a custom AppConsentTVTheme.

3. Then use appConsentTV object

  • Check if user gave consent

Return true if consent is given, false otherwise.

  • Consent listener
Add Listener
appConsentTV.addNoticeListener(object : AppConsentNoticeListener { 
override fun onConsentGiven() {
// ...

override fun onError(error: AppConsentError) {
// ...
Remove Listener

Every time consent is updated, a new event will be fired in AppConsentNoticeListener.

  • Display CMP notice
appConsentTV.presentNotice(false) // display CMP notice only if needed
appConsentTV.presentNotice(true) // force to display CMP notice

presentNotice(force : Boolean) is a local method that only check cache. See checkForUpdate() to fetch a notice update

  • Consentable allowed

Return true if consentable with id = 1 and consentableType = 0 is allowed, false otherwise. The id to pass is the iabId of your purpose and the consentableType is the type, e.g: purpose = 0 .

  • Stack Allowed

Return true if stack with id = 1 is allowed, false otherwise.

  • Vendor allowed

Return true if vendor with id = 1 is allowed, false otherwise.

  • Set consentable status
mapOf(1 to ConsentStatus.ALLOWED, 2 to ConsentStatus.DISALLOWED),
object : AppConsentSetConsentableConsentsCallback {
override fun onSuccess() {
// ...

override fun onError(t: Throwable) {
// ...

Set consentables status, save it and send it to server.

  • Check for update
appConsentTV.checkForUpdate(object : AppConsentUpdateCallback {
override fun onResult(updated: Boolean) {
// ...

override fun onError(t: Throwable?) {
// ...

Check if consent must be updated (new gvl version, new consentables...).

  • Clear consents

Clear consents on mobile, but not on server.

  • Set external data
val map = mapOf<String, Any>("externalId" to "abze23", "otherData" to "{\"name\": \"test\"}")

Set external data and send it to server.

  • Get external data
val map: Map<String, Any> = appConsentTV.getExternalData()

4. Retrieve your consents

Your consents are saved in SharedPreferences of your TV application. To know more about keys used to save your consents, please refer to the IAB documentation.