Skip to main content

Android


Get AppConsent SDK​

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

Declaration of the repository​

Gradle <6.8​

In the build.gradle file at the root of your project, add the following:

repositories {
...
maven {
url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
}
}

Gradle >=6.8​

In your settings.gradle file, at the root of your project, add the following :

dependencyResolutionManagement {
...
repositories {
...
maven {
url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
}
}
}

Library integration​

In your application build.gradle add the following:

dependencies { 
implementation 'com.sfbx.appconsent:appconsent-ui-v3:${currentUIV3Version}'
}

Where currentUIV3Version = 2.0.14


How to use AppConsent​

1. Get your AppKey from AppConsent : https://app.appconsent.io​

GetAppkey

2. Create AppConsent Instance​

import com.sfbx.appconsentv3.ui.AppConsentUIV3

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val appConsent = AppConsentUIV3(
context = this,
appKey = "YOUR_APP_KEY"
) {
it.presentNotice(false)
}
}
}
info

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

3. Then use appConsent object​

For more information please refer to our technical documentation

4. Retrieve your consents​

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

We also provide an additional key for Google Additionnal Consent IABTCF_AddtlConsent returning a String.

5. Xchange​

In your application build.gradle add the following

dependencies { 
implementation 'com.sfbx.appconsent:appconsent-ui-v3-xchange:${currentUIV3Version}'
}

Where currentUIV3Version = 2.0.14

  • Set xchange user data
appConsent.setXchangeUserData(
XChangeUserData.Builder()
.email("test@sfbx.io")
.build()
)

Save user data in cache, and when user give his consent, data are sent to server.

API reference​

The API reference is here.