mediation | GDPR Consent for Third-party SDKs - Android

With Android SDK 902, we have introduced a new API for publishers to pass GDPR consent to various third parties that are part of Aerserv mediation.

public static void setAdapterGdprConsent(@Nullable JSONObject adapterConsentObject)

The consent includes the following partners:

  • ADCOLONY
  • ADMOB
  • APPLOVIN
  • CHARTBOOST
  • FLURRY
  • MILLENNIALMEDIA
  • MOPUB
  • MYTARGET
  • UNITY
  • VUNGLE

Passing the GDPR Consent API

Use the following steps to pass GDPR consent API:

STEP 1: Create a new JSONObject instance as shown below:

		JSONObject adapterConsent = new JSONObject();
	

STEP 2: Add individual consent status for each partner SDK. Refer to the list below for partner-specific list of constants exposed in AdapterConsentKeys. These should be used for passing consent for all listed SDKs.

  1. ADCOLONY:

    Key Type Inference
    KEY_ADCOLONY_GDPR_CONSENT_STRING String Your user's consent string. In this case, the user has given consent to store and process personal information.

    Refer here for more info:

    AS_KEY_ADCOLONY_GDPR_REQUIRED boolean The value passed via setGDPRRequired() will determine the GDPR requirement of the user. If it is true, then the user is subject to the GDPR laws.

    Sample code:

    JSONObject adColony = new JSONObject(); 
    try {
        adColony.put(AdapterConsentKeys.KEY_ADCOLONY_GDPR_REQUIRED, true);
        adColony.put(AdapterConsentKeys.KEY_ADCOLONY_GDPR_CONSENT_STRING, "true");
        adapterConsent.put(AdapterConsentKeys.KEY_ADCOLONY, adColony);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  2. ADMOB:

    Key Type Inference
    KEY_ADMOB_NON_PERSONALIZED_ADS String The default behaviour of the Google Mobile Ads SDK is to serve personalized ads. If a user has consented to receive only non-personalized ads, you can use the below code to request non personalised regardless of whether the user is in the EEA.

    Refer here for more info:

    Sample code:

    JSONObject adMob = new JSONObject();
    try {
        adMob.put(AdapterConsentKeys.KEY_ADMOB_NON_PERSONALIZED_ADS, "1");
        adapterConsent.put(AdapterConsentKeys.KEY_ADMOB, adMob);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  3. APPLOVIN:

    Key Type Inference
    KEY_APPLOVIN_HAS_USER_CONSENT boolean If the user has consented, please set the following key to true else to false.

    Refer here for more info:

    KEY_APPLOVIN_IS_AGE_RESTRICTED_USER boolean To ensure COPPA, GDPR, and Google Play policy compliance, you should indicate when a user is a child. If the user is known to be in an age-restricted category (i.e., under the age of 16) please set the flag to true.

    If the user is known to be not in an age-restricted category (i.e., age 16 or older), please set the flag to false.

    Sample code:

    JSONObject appLovin = new JSONObject(); 
    try { 
        appLovin.put(AdapterConsentKeys.KEY_APPLOVIN_HAS_USER_CONSENT, true);
        appLovin.put(AdapterConsentKeys.KEY_APPLOVIN_IS_AGE_RESTRICITED_USER, true);
        adapterConsent.put(AdapterConsentKeys.KEY_APPLOVIN, appLovin);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  4. CHARTBOOST:

    Key Type Inference
    KEY_CHARTBOOST_PI_DATA_USE_CONSENT Number Set the consent status corresponding to the user's response using the given key.

    Use the number value to represent value of:

    /* Publisher hasn't implemented functionality or the user has the option to not answer. */
    Chartboost.CBPIDataUseConsent.UNKNOWN = -1,
    /* User does not consent to targeting (Contextual ads). */
    Chartboost.CBPIDataUseConsent.NO_BEHAVIORAL  = 0,
    /* User consents (Behavioral and Contextual Ads). */
    Chartboost.CBPIDataUseConsent.YES_BEHAVIORAL = 1
    				

    Refer here for more info:

    Sample code:

    JSONObject chartboost = new JSONObject();
    try {
        chartboost.put(AdapterConsentKeys.KEY_CHARTBOOST_PI_DATA_USE_CONSENT, 1);
        adapterConsent.put(AdapterConsentKeys.KEY_CHARTBOOST, chartboost);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  5. FLURRY:

    Key Type Inference
    KEY_FLURRY_GDPR_SCOPE boolean Key set to true states that GDPR scope apply, while false states that GDPR scope do not apply.
    KEY_FLURRY_CONSENT_STRINGS JSONObject Use this JSONObject to give the value of Consent Strings.

    Refer here for more info:

    Sample code:

    JSONObject flurry = new JSONObject();
    try {
        JSONObject flurryStrings = new JSONObject();
        flurryStrings.put("iab", "<IAB Consent string>");
        flurryStrings.put("consent", "true");
        flurry.put(AdapterConsentKeys.KEY_FLURRY_GDPR_SCOPE, true);
        flurry.put(AdapterConsentKeys.KEY_FLURRY_CONSENT_STRINGS, flurryStrings);
        adapterConsent.put(AdapterConsentKeys.KEY_FLURRY, flurry);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  6. MILENNIALMEDIA:

    Key Type Inference
    KEY_MILLENNIALMEDIA_CONSENT_REQUIRED boolean Set to true if the user falls under GDPR jurisdiction.
    KEY_MILLENNIALMEDIA_CONSENTDATA_IAB String Sets the IAB Consent String.

    Refer here for more info:

    Sample code:

    JSONObject millinealMedia = new JSONObject();
    try {
        millinealMedia.put(AdapterConsentKeys.KEY_MILLENNIALMEDIA_CONSENT_REQUIRED, true);
        millinealMedia.put(AdapterConsentKeys.KEY_MILLENNIALMEDIA_CONSENTDATA_IAB, "true");
        adapterConsent.put(AdapterConsentKeys.KEY_MILLENNIALMEDIA, millinealMedia);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  7. MOPUB:

    Key Type Inference
    KEY_MOPUB_CONSENT boolean Set to true if the user wants to grant consent or false if user wants to revoke consent. This applies only for publisher-owned consent mechanism.

    Refer here for more info:

    Sample code:

    JSONObject mopub = new JSONObject();
    try {
        mopub.put(AdapterConsentKeys.KEY_MOPUB_CONSENT, true);
        adapterConsent.put(AdapterConsentKeys.KEY_MOPUB, mopub);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  8. MYTARGET:

    Key Type Inference
    KEY_MYTARGET_USER_AGERESTRICTED boolean If the user is known to be in an age-restricted category (i.e., under the age of 16) please set the following flag to true.
    KEY_MYTARGET_USER_CONSENT boolean Sets the user has consented(true) or not consented(false) on collect data. In case of not consented, no personal data will be collected and sent to the server.

    Refer here for more info:

    Sample code:

    JSONObject myTarget = new JSONObject();
    try {
        myTarget.put(AdapterConsentKeys.KEY_MYTARGET_USER_AGERESTRICTED, true);
        myTarget.put(AdapterConsentKeys.KEY_MYTARGET_USER_CONSENT, true);
        adapterConsent.put(AdapterConsentKeys.KEY_MYTARGET, myTarget);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  9. UNITY:

    Key Type Inference
    KEY_UNITY_GDPR_CONSENT boolean If the user opts-in to targeted advertising set the key’s value to true else to false.

    Refer here for more info:

    Sample code:

    JSONObject unity = new JSONObject();
    try {
        unity.put(AdapterConsentKeys.KEY_UNITY_GDPR_CONSENT, true);
        adapterConsent.put(AdapterConsentKeys.KEY_UNITY, unity);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		
  10. VUNGLE:

    Key Type Inference
    KEY_VUNGLE_CONSENT_STATUS String To set the user's consent status to opt in, set the key's value to "OPTED_IN". To set the user's consent status to opted out, set the key's value to "OPTED_OUT".

    Refer here for more info:

    KEY_VUNGLE_CONSENT_MESSAGE_VERSION String It sets the consent message version. This value is an arbitrary string and can be used to identify the version of the consent message presented to the user.

    Sample code:

    JSONObject vungle = new JSONObject();
    try {
        vungle.put(AdapterConsentKeys.KEY_VUNGLE_CONSENT_MESSAGE_VERSION, "1.0.0");
        vungle.put(AdapterConsentKeys.KEY_VUNGLE_CONSENT_STATUS, "OPTED_IN");
        adapterConsent.put(AdapterConsentKeys.KEY_VUNGLE, vungle);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    		

STEP 3: Pass the final JSONObject created using the following API:

		AerServSdk.setAdapterGdprConsent(adapterConsent);