Verisoul provides a native Android SDK that allows you to implement fraud prevention in your Android applications. This guide covers the installation, configuration, and usage of the Verisoul Android SDK.

Installation

Repository Setup

Add the Verisoul repository to your project’s settings.gradle file:

dependencyResolutionManagement {
    repositories {
        maven { url = uri("https://us-central1-maven.pkg.dev/verisoul/android") }
    }
}

Add Dependency

Add the Verisoul SDK dependency to your app’s build.gradle file:

For Groovy DSL

dependencies {
    implementation "ai.verisoul:android:0.3.2"
}

For Kotlin DSL

dependencies {
    implementation(libs.verisoul.android)
}

If you’re using the Kotlin DSL with a version catalog, add these lines to your libs.versions.toml file:

Under the [versions] section:

verisoul = "0.3.2"

Under the [libraries] section:

verisoul-android = { group = "ai.verisoul", name = "android", version.ref = "verisoul" }

Permissions

The SDK requires internet access, which is automatically added to your manifest through the SDK’s manifest.

Initialization

Initialize the Verisoul SDK in your Application class:

// In your Application class
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        // Initialize Verisoul
        Verisoul.init(
            this,
            VerisoulEnvironment.Prod, // or Sandbox for testing
            "YOUR_VERISOUL_PROJECT_ID"
        )
    }
}

Don’t forget to register your Application class in the AndroidManifest.xml:

<manifest>
    <application
        android:name=".MyApplication">
            ...
    </application>
</manifest>

When initialized, the Verisoul library will gather initial device data and generate a session ID that will be uploaded to the Verisoul backend.

Usage

Getting the Session ID

Once the minimum amount of data is gathered, the session ID becomes available. The session ID is needed to request a risk assessment from Verisoul’s API. Note that session IDs are short-lived and will expire after 24 hours.

// Kotlin
Verisoul.getSessionId(
    callback = object : VerisoulSessionCallback {
        override fun onSuccess(sessionId: String) {
            Log.d("Verisoul", "Session ID: $sessionId")

            // Pass sessionId to backend to get a Verisoul decision
        }
        
        override fun onFailure(exception: Exception) {
            Log.e("Verisoul", "Error getting session ID: ${exception.message}")
        }
    }
)

Providing Touch Events

To gather touch events and compare them to device accelerometer sensor data, you need to provide touch events to Verisoul. Create a BaseActivity class, override the dispatchTouchEvent function, and pass the data to Verisoul:

open class BaseActivity : AppCompatActivity() {
    override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
        Verisoul.onTouchEvent(event)
        return super.dispatchTouchEvent(event)
    }
    
    // Other common BaseActivity code...
}

Then use this BaseActivity as the base class for your activities:

class MainActivity : BaseActivity() {
    // Your activity code...
}

Next Steps