> >

Android

Resource and Overview

The GeeTest iOS SDK is provided to developers who are integrating it into Android native client development

Environment and Requirements

Item Resources
Development object Android 4.4+
Developing environment Android Studio 4.1
Compilation Tools gradle (For ant compilation, please decompress and extract jar and resource files from the package)
System Denpendenies None
SDK Third-Party Dependencies None

Installation

Get the SDK

Please contact your account manager to get the SDK

Import SDK

Take the .aar file from the zip package (including geetest_geeguard_android_vx.y.z_date.aar) and drag it into the libs folder in your project. After dragging the .aar file into the libs folder, make sure to check if the .aar file has been added to the Library. You also need to add the following code to your project’s build.gradle file:

repositories {
flatDir {
dirs 'libs'
}
}

And you need to manually add the aar package as a dependency:

implementation(name: 'geetest_geeguard_android_vx.y.z_date', ext: 'aar')

Add permission statement

<!--Required - Default value is apply-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Optional - For Android 6.0 and above, dynamic permission is required (to store logs for analyzing anomalies). -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Configuration of Obfuscation Rules

The Geetest SDK has already undergone obfuscation. When integrating, please include the obfuscation rules and do not obfuscate the SDK again.

-dontwarn com.geetest.geeguard.**
-keep class com.geetest.geeguard.**{*;}

The call logic

  1. Register and obtain an AppID on the dashboard
  2. Obtain GeeGuardReceipt through AppID

    For code integration, please refer to the sample code below

Sample code

Access applicable to version 2.3.0 and above

Create the appID on the GeeTest dashboard immediately after the application starts

// Your AppID
const val appId = "123456789012345678901234567890ab"

class APP : Application() {
override fun onCreate() {
super.onCreate()
GeeGuard.register(this, appId)
}
}

Get GeeToken

Sign the data by using the GeeGuardSDK and obtain the environmental detection GeeToken.

// Get GeeToken directly, requires parsing the result on the server side
fun getGeeToken(context: Context) {
thread {
val data = "The sole mark of the data or transaction for this business serial number, for the purpose of business correlation and validation."

val receipt = GeeGuard.fetchReceipt(context, data)
if (receipt != null) {
//Submit along with business data, please obtain the final environmental identification result and fingerprint on the server side.
// Please refer to the server-side documentation for the API parameters.
Log.i("GeeToken: ${receipt.geeToken}")
} else {
Log.w("Unable to obtain GeeGuardReceipt, please check if you have registered the AppID through GeeGuard.register(appId).")
}
}
}

// Get the respondedGeeToken, which needs to be parsed on the server-side.
// This function callback is asynchronous.
fun getRespondedGeeToken(context: Context) {
thread {
val data = "The sole mark of the data or transaction for this business serial number, for the purpose of business correlation and validation."
if (status == 200) {
//Submit along with business data, please obtain the final environmental identification result and fingerprint on the server side.
// Please refer to the server-side documentation for the API parameters.
text.postValue("RespondedGeeToken: ${receipt.respondedGeeToken}")
} else {
text.postValue("Status: $status")
}
}
}
}

Error Code

The possible error codes that may be returned in the asynchronous retrieval method GeeGuard.submitReceipt(Context, String, GeeGuard.CallbackHandler) include:

Error code Description
-200 Unregistered AppID, please register an AppID after starting+
-300 Network error, please refer to the information in the userInfo of the error object for details1
-500 Service response format is abnormal, please check receipt.originalResponse for details
-501 Service response failure, please check receipt.originalResponse for details.

Querying GeeToken Result

Submit respondedGeeToken or GeeToken along with business data to the business server, which will then query the result from the GeeTest Device Fingerprinting Service. For more details, refer to the server-side documentation.

Was this helpful?
Send