Android CMP
Android CMP Integration Manual
Release Note (v7.2.2)
1. Overview
SDK provides a Consent Collection feature or CMP. The SDK currently implements TCF v2. The TC string generated by the SDK is available to callers and can be found in the standard location as per TCF v2 specification.
2. Use Java 17 in your project
Put this setting into your gradle file
compileOptions {
targetCompatibility = "17"
}3. Add SDK dependency to your project
Using Gradle:
Add our maven reference into your project setup (in buildscript and allprojects)
...
buildscript {
repositories {
mavenCentral()
google()
maven { url 'https://slabs-yieldlove-ad-integration.s3.eu-central-1.amazonaws.com/android'
content{ includeGroup("com.yieldlove.adIntegration")}
}
}
}
...
...
allprojects {
repositories {
mavenCentral()
google()
maven { url 'https://slabs-yieldlove-ad-integration.s3.eu-central-1.amazonaws.com/android'
content{ includeGroup("com.yieldlove.adIntegration")}
}
}
}
...Use dependency to our libraries
implementation 'com.yieldlove.adIntegration:cmp:7.2.2'4. Before you start
Receive an APPLICATION_NAME (to be set only once).
5. Set up application name
Before the beginning, you need to set up APPLICATION_NAME property. This needs to be done only once.
Yieldlove.setApplicationName(getApplicationContext(), "APPLICATION_NAME");6. Consent Collection (CMP)
6.1. Simple Consent Message
Simple Consent Message displays a view that contains legal information about how user’s data are collected and handled and usually two buttons, "Accept All" and "Manage My Options" (exact wording may vary and may appear translated).
To collect consent using a Simple Consent Message from users of your app, first initialize YieldloveConsent class, then call collect() API method:
NOTE:
this is Activity context. R.id.main is ID of your main activity layout.
Simple Consent Message will not show if consent has already been provided by the user in the past. Calling this method again after consent was provided will NOT show the Simple Consent Message. This is a feature. It allows app developer to call the method on application start without checking if consent has been provided before.
YieldloveConsent consent = new YieldloveConsent(
this,
R.id.main);
consent.collect(MessageLanguage.ENGLISH);Note: Message language is optional parameter
6.2. Privacy Manager
Privacy Manager displays a more detailed view, where user can consent to individual purposes of their data collection and handling, and choose to share their data with specific vendors. It is the same view that is also accessible using "Manage My Options" button in the Simple Consent Message view.
To display Privacy Manager, first initialize YieldloveConsent class, then call showPrivacyManager() API method:
YieldloveConsent consent = new YieldloveConsent(
// ... use same code like previous code example
);
consent.showPrivacyManager(MessageLanguage.ENGLISH);If it is set (on your consent account), You can also choose the privacy manager layout by calling showPrivacyManager("Your-Privacy-Manager-Layout-Name"), see below:
YieldloveConsent consent = new YieldloveConsent(
// ... use same code like previous code example
);
consent.showPrivacyManager("Your-Privacy-Manager-Layout-Name", MessageLanguage.ENGLISH);Note: Message language is optional parameter in both methods.
6.3. Reacting to App User’s Actions and Errors when Collecting Consent
Use YieldloveConsentListener to react to consent events. You may need to manually show consent view and remove it after user action (see example below).
These events are supported:
OnConsentUIReady (called when the message is ready to be displayed. Here you must render the consent view.)
OnConsentUIFinished (called when the message is ready to disappear. Here you must hide the consent view.)
OnConsentReady (called when the user finishes interacting with the consent view)
OnError (called when something wrong happens in the consent view)
YieldloveConsent consent = new YieldloveConsent(
this,
new YieldloveConsentListener() {
@Override
public void OnConsentUIReady(View consentView) {
if (view.getParent() == null) {
// R.id.main is your main activity layout
ViewGroup parent = findViewById(R.id.main);
consentView
.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
consentView.bringToFront();
consentView.requestLayout();
parent.addView(consentView);
}
}
@Override
public void OnConsentUIFinished(View consentView) {
ViewGroup parent = findViewById(R.id.main);
parent.removeView(consentView);
}
@NonNull
@Override
public ConsentAction onAction(@NonNull View view, @NonNull ConsentAction consentAction) {
return consentAction; // DO NOT FORGET TO RETURN consentAction
}
...
// other methods required by interface
});
consent.collect();6.4. Programmatically consenting current user
It fully mimics and use
customConsentToa method from SourcePoint CMP
It's possible to programmatically consent the current user to a list of vendors, categories and legitimate interest categories by using the following method from the consentlib:
customConsentTo(
ArrayList<String> vendors,
ArrayList<String> categories,
ArrayList<String> legIntCategories,
OnConsentReadyCallback onCustomConsentReady
)or
customConsentTo(
ArrayList<String> vendors,
ArrayList<String> categories,
ArrayList<String> legIntCategories,
CustomConsentListener customConsentListener
)6.5. Authenticated Consent
If you want to use Authenticated Consent feature, use constructor of YieldloveConsent with authId property
YieldloveConsent consent = new YieldloveConsent(
this,
R.id.main,
"<authId>");
consent.collect();6.6. PUR and other programmatically controlled consent layers
To see PUR (or different) CMP layer (layout), you can call function collect or showPrivacyManager with layoutName parameter.
To know which layoutName you can use as parameter, ask publisher account management for the value of this property, the same person who gave you APPLICATION_NAME.
String layoutName = "purLayer"; // this "purLayer" is just example, not real value
YieldloveConsent consent = new YieldloveConsent(this, new YieldloveConsentListener() {... ...});
consent.collect(layoutName);
OR
consent.showPrivacyManager(layoutName);7. Clear Consent
To clear a previously stored consent this method is available:
Clear a previously stored consent
...
YieldloveConsent consent = new YieldloveConsent(
this,
R.id.main,
"<authId>");
...
consent.clearConsent();
...