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
file, add:
repositories {
..
maven {
url 'https://dl.cloudsmith.io/$TOKEN/credolab/proxyen-sdk/maven/'
}
}
2. Declare dependencies
In the app build.gradle
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.application: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'
implementation 'com.credolab:modular.sms:X.Y.Z'
// FraudForce module
implementation 'com.credolab:modular.fraudforce:X.Y.Z'
implementation 'com.credolab:iovation: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'
}
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'
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
// if you use BehavioralModule, init it first
val behavioralModule = BehavioralModule()
BehavioralModule.startTracking()
val credoAppService = CredoAppService.Builder(applicationContext)
.addModule(ApplicationModule())
.addModule(AudioModule())
.addModule(CalendarModule())
.addModule(ContactModule())
.addModule(FraudForceModule())
.addModule(ImagesModule())
.addModule(RegisterAccountModule())
.addModule(SmsModule())
.addModule(VideoModule())
.addModule(behavioralModule)
.addPlugin(LoggingPlugin())
.build()
// if you use BehaviouralModule, init it first
BehaviouralModule behaviouralModule = new BehaviouralModule();
BehaviouralModule.startTracking();
CredoAppService credoAppService = new CredoAppService.Builder(applicationContext)
.addModule(new ApplicationModule())
.addModule(new AudioModule())
.addModule(new CalendarModule())
.addModule(new ContactModule())
.addModule(new FraudForceModule())
.addModule(new ImagesModule())
.addModule(new RegisterAccountModule())
.addModule(new SmsModule())
.addModule(new VideoModule())
.addModule(behavioralModule)
.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.
Next Steps
After successfully integrating our SDK, it is recommended to proceed with the following steps to utilise our platform effectively:
- Setting up your Reverse Proxy
- Uploading your Dataset. Once the server is configured, you can upload your dataset using the server address.
- Collecting your Dataset Insight. With the dataset uploaded, you can now get insights.
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.
Updated about 1 year ago