libs
..aar
file into the libs
directory.Initialize the SDK in your Application
class or the onCreate
method of your main Activity
:
import android.app.Application
import android.view.MotionEvent
import com.cleartrust.cleartrustadfraudtestingapp.android.ct_fraud_detection_sdk.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class MyApplication : Application() {
private lateinit var CTSessionManager: CTSessionManager
private lateinit var CTDeviceMovementMonitor: CTDeviceMovementMonitor
private lateinit var CTTouchTracker: CTTouchTracker
private lateinit var CTApiClient: CTApiClient
private lateinit var CTDeviceInfoManager: CTDeviceInfoManager
private lateinit var fraudScore: CTFraudScore
private lateinit var CTAppUtils: CTAppUtils
override fun onCreate() {
super.onCreate()
CTApiClient = CTApiClient(this)
CTAppUtils = CTAppUtils(this)
CTDeviceInfoManager = CTDeviceInfoManager(this)
CTSessionManager = CTSessionManager(CTApiClient)
CTDeviceMovementMonitor = CTDeviceMovementMonitor(application, CTAppUtils, this)
CTTouchTracker = CTTouchTracker()
val uuid = CTAppUtils.ctGetDeviceInfo().uuid
val apiKey = "YOUR_AUTHORIZATION_KEY"
fraudScore = CTFraudScore(this, uuid, apiKey, s1="", s2="", s3="", s4="", s5="", s6="")
fraudScore.startFraudScoreUpdates()
CTAppUtils.ctRequestPermissions(this)
val coroutineScope = CoroutineScope(Dispatchers.Main)
coroutineScope.launch {
fraudScore.ctGetFraudScore()
}
CTDeviceMovementMonitor.startMonitoring()
}
override fun onDestroy() {
super.onDestroy()
CTDeviceMovementMonitor.stopMonitoring()
fraudScore.stopFraudScoreUpdates()
}
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
CTTouchTracker.trackTouches(event, this)
return super.dispatchTouchEvent(event)
}
}
YOUR_AUTHORIZATION_KEY
with your actual authorization key:val apiKey = "YOUR_AUTHORIZATION_KEY"
AndroidManifest.xml
file:<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
Update your build.gradle.kts
file with the following dependencies:
dependencies {
// Your existing dependencies
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("androidx.lifecycle:lifecycle-process:2.6.2")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation("com.google.code.gson:gson:2.8.8")
}
The fraud score is calculated based on various factors. To retrieve the score from the SDK, use the following function:
val score = fraudScore.ctGetFraudScore()
If the function returns null
, default the value to 0
.
s1
to s6
) during the initialization of CTFraudScore
:fraudScore = CTFraudScore(this, uuid, apiKey, s1="value1", s2="value2", s3="value3", s4="value4", s5="value5", s6="value6")
8.Bundle ID and App Name
Pass your application's Bundle ID and App Name to the SDK by setting the s5
and s6
parameters
during the initialization of CTFraudScore
.fraudScore = CTFraudScore(
context = this,
uuid = uuid,
apiKey = apiKey,
s1 = "",
s2 = "",
s3 = "",
s4 = "",
s5 = "your.bundle.id", // Replace with your actual Bundle ID
s6 = "YourAppName" // Replace with your actual App Name
)
Ensure you replace "your.bundle.id"
and "YourAppName"
with your application's actual Bundle ID and App Name
This completes the integration of the ClearTrust Fraud Detection SDK into your Android project.