SDK integration

Initial setup

The latest SDK library file: 2.2.1 (September 2019)

Repository

Add a new maven repository in the main build.gradle project file:

allprojects {
    repositories {

        /* ... */

        maven {
            url "https://nexus.vectaury.io/repository/sdk/"
        }
    }
}

Dependencies

You can now add the dependency to the library in the my_app_module/build.gradle file.

dependencies {
    /* ... */

    // Vectaury CMP
    implementation 'io.vectaury.android:cmp:2.2.1'
}

Manifest and Application

In your custom application file, initialize the CMP as soon as possible, with xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx being the API key provided by Vectaury:

package com.app.my;

import android.app.Application
import io.vectaury.android.sdk.Vectaury

class CustomApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        val apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        val config = VectauryConsentConfig.Builder(this, apiKey).build()

        VectauryConsent.init(this, config)

        /* ... */
    }

}
package com.app.my;

import android.app.Application;
import io.vectaury.android.sdk.Vectaury;

public class MyApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        String apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
        VectauryConsentConfig config = new VectauryConsentConfig.Builder(this, apiKey).build();

        VectauryConsent.init(this, config);

        /* ... */
    }

}

In your code

To ask the consent to the user, add the following line in your navigation workflow, for example on your splash screen or home screen:

VectauryConsent.ask(activity)
VectauryConsent.ask(activity);

You can check if you need to wait or if you can continue your process (the case in a splash screen for example):

val uiWillStart = VectauryConsent.ask(activity)
if (uiWillStart) {
    // do nothing and wait that the CMP is close
} else {
    continueProcess()
}
boolean uiWillStart = VectauryConsent.ask(activity);
if (uiWillStart) {
    // do nothing and wait that the CMP is close
} else {
    continueProcess();
}

You can know if the CMP has finished with the following method in your activity:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    if (VectauryConsent.isFromConsent(requestCode, resultCode, data)) {
        // Come from CMP Screen
        continueProcess()
    } else {
        super.onActivityResult(requestCode, resultCode, data)
    }
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (VectauryConsent.isFromConsent(requestCode, resultCode, data)) {
        // Come from CMP Screen
        continueProcess();
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

The user needs to be able to edit the consent. You can open the consent UI with the following method:

VectauryConsent.display(this)
VectauryConsent.display(this);