SDK integration

Initial setup

The latest SDK library file: 2.0.6 (July 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 SDK
    implementation 'io.vectaury.android:sdk:2.0.6'
}

Manifest and Application

If not already, your my_app_module/src/main/AndroidManifest.xml file must look like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.my">
    <application android:name=".MyApp" [...]>
        <activity [...]>[...]</activity>
    </application>
</manifest>

Also, the application file my_app_module/src/main/java/com/app/my/MyApp.java must look like this, 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"
        Vectaury.start(this, apiKey, ConsentMode.CMP_IAB, LegIntMode.MANUAL)

        /* ... */
    }

}
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";
        boolean defaultOptin = false;
        Vectaury.start(this, apiKey, ConsentMode.CMP_IAB, LegIntMode.MANUAL);

        /* ... */
    }

}

Warning

Check the following part to choose the correct Consent Mode when initializing the SDK.

Note

With GDPR, the consent of the user is mandatory before collecting data in UE. You must use a CMP.

The SDK will automatically start ad stop according to the IAB CMP status. Because IAB specifications missing some purposes to collecting location data, each CMP has implemented their own way to manage it. If your are using one of the following CMP, please initialize the SDK with the correct ConsentMode:

  • For Vectaury CMP:

Vectaury.start(this, apiKey, ConsentMode.CMP_VECTAURY, LegIntMode.MANUAL);

  • For Singlespot CMP:

Vectaury.start(this, apiKey, ConsentMode.CMP_SINGLESPOT, LegIntMode.MANUAL);

  • For Chandago CMP:

Vectaury.start(this, apiKey, ConsentMode.CMP_CHANDAGO, LegIntMode.MANUAL);

  • For Fidzup CMP:

Vectaury.start(this, apiKey, ConsentMode.CMP_FIDZUP, LegIntMode.MANUAL);

Permissions

In order to run properly, the library needs the following permissions:

  • android.permission.ACCESS_FINE_LOCATION: (see special note bellow) used to get the device last known location
  • android.permission.ACCESS_NETWORK_STATE: used to detect if the device has connectivity
  • android.permission.INTERNET: used to allow the library to send over the internet the data it has collected
  • android.permission.RECEIVE_BOOT_COMPLETED: used to initialized the library when the device has booted

You don't need to add those permission to your AndroidManifest.xml unless your application already uses them ; they are automatically added to the merged manifest by the library (using the element).

Get location data

Since Android 6.0 (API level 23), this permission is belongs to the "dangerous permissions" and must be requested at run time.

The library does not implement this mechanism as it could interfere with your application's behavior.

It is therefore your job to ask the user to grant the permission. This is very well described in the official Android documentation.