Sample application for Liveness SDK
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://maven.pkg.github.com/surepassio/liveness-android-sdk-sample-app"
credentials {
username = "GITHUB_USER_NAME"
password = "GITHUB_PAT_TOKEN" //https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token (Allow Package Install Permission)
}
}
}
}
- Incase of Version 1, Add following:
dependencies {
....
'implementation 'io.surepass.sdk:liveness-android-sdk:1.0.8' // without Face Mask Detection
}
- Incase of Verion 2, Add following:
android {
....
aaptOptions {
noCompress '.tflite'
}
}
dependencies {
....
'implementation 'io.surepass.sdk:liveness-android-sdk:2.2.2' // with Face Mask Detection
}
import io.surepass.livenessandroidsdk.ui.InitSDK
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//token is needed when using liveness sdk
val token = "TOKEN"
val env = "PREPROD" // "PROD" or "PREPROD"
val videoUpload = false
var instructions = arrayOf("Clear you background","Remove glasses",...)
val intent = Intent(this, InitSDK::class.java)
intent.putExtra("token",token)
intent.putExtra("env",env) // Optional (Default: PREPROD)
intent.putExtra("videoUpload",videoUpload) // Optional (Default: true)
intent.putExtra("videoPlayBackDisable",true) // Optional (Default: false)
intent.putExtra("instructionsArray" , instructions)
startActivityForResult(intent , 10000)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
10000 -> {
val response = data!!.getStringExtra("response");
Log.d("CONSOLE", "response $response")
}
}
}
}
SurePass Liveness Android SDK returns following response depending on the status of process.
Note: Only the 200 SUCCESS status sent to onActivityResult
function represents successful process. Rest, all the other responses are dispatched to the onActivityResult
function are errors.
Returns HTTP status of 200 OK, when the Liveness process has been completed successfully.
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 200,
"message_code": "SUCCESS",
"message": "Successfully Completed",
"success": true
}
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 401,
"message_code": "UNAUTH_ACCESS",
"message": "Invalid Token",
"success": false
}
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 403,
"message_code": "TOKEN_EXPIRED",
"message": "Token Expired",
"success": false
}
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 450,
"message_code": "UNSUPPORTED_DEVICE",
"message": "Device not supported",
"success": false
}
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 433,
"message_code": "SDK_CLOSED",
"message": "User closed the SDK before process completed",
"success": false
}
Alternative Message
: "Face Not Found", "Face Mask Found", "Exceeded Attempts", "Multiple Faces Found"
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 500,
"message_code": "INT_SERVER_ERROR",
"message": "Something went wrong. Try again later",
"success": false
}
{
"data": {
"client_id": "CLIENT_ID"
},
"status_code": 501,
"message_code": "TIMEOUT_ERROR",
"message": "Session Timeout Occurred",
"success": false
}
The SDK language can be customized by overriding the string in main strings.xml
. At the moment, we support and maintain translations for English (default) only.
- The keys can be found in
io/surepass/sdk/liveness-android-sdk/app/src/main/res/values/strings.xml
. They can be passed as a string in the main applicationstrings.xml
to override.