Integration

The minimal supported Android version is 5.0 Lollipop.
Programming language Kotlin or Java.

๐Ÿ“˜

Before you start

Make sure you've obtained a token, server URL, and auth key from credolab

1. Add a repository

In the project build.gradle or settings.gradle file, add:

repositories {
  ..
  maven {
    url 'https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/'
  }
}
repositories {
  ..
  maven {
    url = uri("https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/")
  }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
				..
        maven {
            url "https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/"
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
				..
        maven {
            url = uri("https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/")
        }
    }
}

โš ๏ธ

Note

Replace $TOKEN with actual token obtained from credolab

2. Declare dependencies

In the app build.gradle or build.gradle.kts file, add the following

dependencies {
    // Required for core module
    implementation 'com.google.code.gson:gson:2.8.5'

    // Core module
    implementation 'com.credolab:modular.core:X.Y.Z'

    // Modules: each module is optional
    implementation 'com.credolab:modular.account:X.Y.Z'
    implementation 'com.credolab:modular.behavioral:X.Y.Z'
    implementation 'com.credolab:modular.calendar:X.Y.Z'
    implementation 'com.credolab:modular.contact:X.Y.Z'
    implementation 'com.credolab:modular.audio:X.Y.Z'
    implementation 'com.credolab:modular.images:X.Y.Z'  
    implementation 'com.credolab:modular.video:X.Y.Z'
  
    // Since version `4.6.0`, the `Core` module includes functionality for collecting application metadata. 
    // If you are using the `Core` module version `4.6.0` or higher, 
    // there's no need to include the `Application` module in your app.
    // implementation 'com.credolab:modular.application:X.Y.Z

    // If your project is on Java
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.0' * โ€”  for Java project

    // Optional: if you want to use logging module
    implementation 'com.credolab:modular.logging:X.Y.Z'
    implementation 'io.sentry:sentry-android:6.3.1'
}
dependencies {
    // Required for core module
    implementation("com.google.code.gson:gson:2.8.5")

    // Core module
    implementation("com.credolab:modular.core:X.Y.Z")

    // Modules: each module is optional
    implementation("com.credolab:modular.account:X.Y.Z")
    implementation("com.credolab:modular.behavioral:X.Y.Z")
    implementation("com.credolab:modular.calendar:X.Y.Z")
    implementation("com.credolab:modular.contact:X.Y.Z")
    implementation("com.credolab:modular.audio:X.Y.Z")
    implementation("com.credolab:modular.images:X.Y.Z")
    implementation("com.credolab:modular.video:X.Y.Z")

    // Since version `4.6.0`, the `Core` module includes functionality for collecting application metadata. 
    // If you are using the `Core` module version `4.6.0` or higher, 
    // there's no need to include the `Application` module in your app.
    // implementation("com.credolab:modular.application:X.Y.Z")

    // Optional: if you want to use logging module
    implementation("com.credolab:modular.logging:X.Y.Z")
    implementation("io.sentry:sentry-android:6.3.1")
}

โš ๏ธ

Note

Please replace X.Y.Z with module versions from Android page.
The final result should look like this:

implementation 'com.credolab:example:4.0.0'
implementation("com.credolab:example:4.0.0")

3. Modify AndroidManifest

Click on the recipe to see what you need to add to your manifest file.

Also, whenever minSdkVersion is lower than 21 API, please wrap SDK calls with version check:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
	credoAppService = CredoAppService.Builder(applicationContext)
}

4. Build and use CredoAppService

Add this code to the onCreate method in your MainActivity.kt file

// When using the BehavioralModule, you can invoke the startTracking method at any point, 
// even before the SDK is initialized.
BehavioralModule.startTracking()

val credoAppService = CredoAppService.Builder(applicationContext)
        .addModule(AudioModule())
        .addModule(BehavioralModule())
        .addModule(CalendarModule())
        .addModule(ContactModule())
        .addModule(ImagesModule())
        .addModule(RegisterAccountModule())
        .addModule(VideoModule())
        .addPlugin(LoggingPlugin())
        .build()
// When using the BehavioralModule, you can invoke the startTracking method at any point, 
// even before the SDK is initialized.
BehavioralModule.startTracking();

CredoAppService credoAppService = new CredoAppService.Builder(applicationContext)
        .addModule(new AudioModule())
        .addModule(new BehavioralModule())
        .addModule(new CalendarModule())
        .addModule(new ContactModule())
        .addModule(new ImagesModule())
        .addModule(new RegisterAccountModule())
        .addModule(new VideoModule())
        .addPlugin(new LoggingPlugin())
        .build();

Now, you're able to use the service

val result = credoAppService.collect()
when (result) {
   is CredoAppResult.Success -> Log.d(TAG, result.value)
   is CredoAppResult.Error -> Log.d(TAG, "${result.message} ${result.code}")
}
CredoAppResult<String> result = credoAppService.collect();

if (result instance of CredoAppResult.Success) {
  Log.d(TAG, ((CredoAppResult.Success<String>) result).getValue());
} else {
  CredoAppResult.Error error = (CredoAppResult.Error) result;
  String errorMessage = (error.getMessage() + " " + error.getCode());
  Log.d(TAG, errorMessage);
}

โ—

Note

Remember that you always must call collect method on a background thread.

If collect is successful, it will return the dataset value.

๐Ÿ“˜

Note

Please refer to BehavioralModule section for additional information about module integration.

Next Steps

After successfully integrating our SDK, it is recommended to proceed with the following steps to utilise our platform effectively:

  1. Setting up your Reverse Proxy
  2. Uploading your Dataset. Once the server is configured, you can upload your dataset using the server address.
  3. Collecting your Dataset Insight or TruValidate(formerly known as iovation) Fraud Check. With the dataset uploaded, you can now get insights or perform TruValidate Fraud Checks to assess risk based on the device and transaction details provided.

Upload from an Android Device

If you are interested in uploading datasets directly from an Android device to our servers, we invite you to explore the following code snippets. These examples can provide valuable guidance and assistance in implementing the upload functionality.

If you have any further questions, please do not hesitate to contact us.