Customize the CMP

Customize IAB vendors

By default, all IAB vendors will be displayed. Unlike some others CMP, we advice you to set only vendors that you use in your application. To do this, just give the vendors id in the configuration object used to initilise the SDK:

val config = VectauryConsentConfig.Builder(context, apiKey)
    .addVendor(368)
    .addVendor(123)
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(context, apiKey)
    .addVendor(368)
    .addVendor(123)
    .build();

Custom (non-IAB) vendors

Not all partners are registered to IAB. Maybe one of them need consent. And to avoid multiple consent interface, we give the possibility to manage non-IAB vendors with our CMP.

Add custom vendors

Just add the custom vendors in the configuration object when initializing the CMP SDK:

val config = VectauryConsentConfig.Builder(context, apiKey)
    .addCustomVendor(
        CustomVendor(
            123,                        // ID of your custom vendor
            "Custom Vendor 123",        // Name of your custom vendor
            "https://www.vectaury.io",  // URL to the custom vendor privacy policy
            Arrays.asList(1, 2, 5),     // IDs of IAB purposes used by the custom vendor
            Arrays.asList(1, 2)         // IDs of IAB features used by the custom vendor
        )
    )
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(context, apiKey)
    .addCustomVendor(
        new CustomVendor(
            123,                        // ID of your custom vendor
            "Custom Vendor 123",        // Name of your custom vendor
            "https://www.vectaury.io",  // URL to the custom vendor privacy policy
            Arrays.asList(1, 2, 5),     // IDs of IAB purposes used by the custom vendor
            Arrays.asList(1, 2)         // IDs of IAB features used by the custom vendor
        )
    )
    .build();

When the user save consent paramters, a callback is triggered by the CMP. Then, you can opt-in or opt-out your custom vendors depending of the consent returns by the CMP:

val config = VectauryConsentConfig.Builder(context, apiKey)
    .setCustomVendorListener { customVendors, consentString ->
        customVendors.forEach {
            val customVendorId = it.id
            if (customVendorId == 123) {
                if (consentString.isCustomVendorAllowed(customVendorId)) {
                    // custom vendor 123 has consent
                } else {
                    // custom vendor 123 has not consent
                }
            }
        }
    }
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(context, apiKey)
    .setCustomVendorListener(new VectauryCmpCustomVendorListener() {

        @Override
        public void onCustomVendorOptinChanged(@NonNull List<CustomVendor> customVendors, @NonNull VectauryConsentString consentString) {
            for (CustomVendor customVendor : customVendors) {
                int customVendorId = customVendor.getId();
                if (customVendorId == 123) {
                    if (consentString.isCustomVendorAllowed(customVendorId)) {
                        // custom vendor 123 has consent
                    } else {
                        // custom vendor 123 has not consent
                    }
                }
            }
        }
    })
    .build();

Or, you can request at any moment the current consent status with the following method:

val customVendorId = 123
val vectauryConsent = VectauryConsent.getVectauryConsentString(context)
if (vectauryConsent.isCustomVendorAllowed(customVendorId)) {
    // custom vendor 123 has consent
} else {
    // custom vendor 123 has not consent
}
int customVendorId = 123;
VectauryConsentString vectauryConsent = VectauryConsent.getVectauryConsentString(context);
if (vectauryConsent.isCustomVendorAllowed(customVendorId)) {
    // custom vendor 123 has consent
} else {
    // custom vendor 123 has not consent
}

Customize theme

The CMP use the Material Design colors (primary, primaryDark and accent). By default, the CMP will use the following colors name:

<color name="colorPrimary">#??????</color>
<color name="colorPrimaryDark">#??????</color>
<color name="colorAccent">#??????</color>

If you want to override the theme colors specifically for the CMP, add and edit the following colors in your colors.xml:

<color name="vectaury_cmp_accent">@color/yourOwnAccentColor</color>
<color name="vectaury_cmp_primary">@color/yourOwnPrimaryColor</color>
<color name="vectaury_cmp_primary_dark">@color/yourOwnPrimaryDarkColor</color>

Customize privacy notice

The privacy notice is the first screen displayed to the user when asking consent.

You can add your own logo at the top of the privacy notice. For this, provide the drawable resource id in the configuration object used to initilise the SDK:

val config = VectauryConsentConfig.Builder(context, apiKey)
    .setLogo(R.drawable.logo)
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(context, apiKey)
    .setLogo(R.drawable.logo)
    .build();

Add your privacy policy

You need to provide your privacy policy to the user. For this, provide your privacy policy url in the configuration object used to initilise the SDK:

val config = VectauryConsentConfig.Builder(context, apiKey)
    .setPrivacyPolicy("https://www.vectaury.io/en/personal-data")
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(context, apiKey)
    .setPrivacyPolicy("https://www.vectaury.io/en/personal-data")
    .build();

Force subject to GDPR

By default, the CMP is displayed only when the user is in EU (based on IP). We advice you to give access to the CMP UI even if the user is not in EU, for this, force the user to be subject to GDPR in the configuration object used to initilise the SDK:

val config = VectauryConsentConfig.Builder(this, apiKey)
    .setSubjectToGdpr(true)
    .build()
VectauryConsentConfig config = new VectauryConsentConfig.Builder(this, apiKey)
    .setSubjectToGdpr(true)
    .build();

You can get the encoded consent string with the following code:

import io.vectaury.cmp.consentstring.IABConstants

val encodedConsentString = PreferenceManager.getDefaultSharedPreferences(context.applicationContext).getString(IABConstants.IAB_CONSENT_STRING, null)
import io.vectaury.cmp.consentstring.IABConstants;

String encodedConsentString = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).getString(IABConstants.IAB_CONSENT_STRING, null);

To get the decoded consent string:

import io.vectaury.cmp.VectauryConsent
import io.vectaury.cmp.consentstring.IABConstants
import io.vectaury.cmp.consentstring.VectauryConsentString

fun isMySdkShouldBeEnabled(context: Context): Boolean {
    val consentString = VectauryConsent.getVectauryConsentString(this)

    val iabPublisherPurposeAllowed = consentString.isPublisherPurposeAllowed(1)
    val customPublisherPurposeAllowed = consentString.isPublisherCustomPurposeAllowed(1)
    val aCustomVendor = consentString.isCustomVendorAllowed(1)

    return iabPublisherPurposeAllowed && customPublisherPurposeAllowed && aCustomVendor
}
import io.vectaury.cmp.VectauryConsent;
import io.vectaury.cmp.consentstring.IABConstants;
import io.vectaury.cmp.consentstring.VectauryConsentString;


public boolean isMySdkShouldBeEnabled(Context context) {
    VectauryConsentString consentString = VectauryConsent.getVectauryConsentString(this);

    boolean iabPublisherPurposeAllowed = consentString.isPublisherPurposeAllowed(1);
    boolean customPublisherPurposeAllowed = consentString.isPublisherCustomPurposeAllowed(1);
    boolean aCustomVendor = consentString.isCustomVendorAllowed(1);

    return iabPublisherPurposeAllowed && customPublisherPurposeAllowed && aCustomVendor;
}