A Flutter plugin that wraps the native VeriLive SDKs for Android and iOS.
It provides a Dart API for performing liveness verification on both platforms.
The plugin opens the native verification screen and returns the result to your Flutter application.
Requirements
Minimum requirements
Component | Minimum version |
|---|---|
Flutter | 3.3.0 |
Dart SDK | 3.12.2 |
Android Min SDK | API 24 |
Android Compile SDK | API 36 |
iOS | 14.0 |
Installation
Add the dependency to
pubspec.yaml:
dependencies:
verilive_sdk:
git:
url: https://<YOUR_GITHUB_PAT>@github.com/verigram/verilive2-sdk-flutter.git
ref: main
Fetch the package:
flutter pub get
Android
The plugin uses the native Android SDK distributed through a private GitLab Maven repository. Add the repository to android/settings.gradle in your Flutter project:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven {
url = uri("https://gitlab.com/api/v4/projects/75704481/packages/maven")
credentials(HttpHeaderCredentials::class) {
name = "Deploy-Token"
value = "<YOUR_DEPLOY_TOKEN>"
}
authentication {
create<HttpHeaderAuthentication>("header")
}
content {
includeGroupByRegex("kz\\.verigram.*")
}
}
}
}
iOS
The plugin distributes the iOS XCFramework through CocoaPods.
No additional configuration is required.
Integration Steps
1. Create a session on the backend
Send a POST request to the /liveness2/session endpoint:
#!/usr/bin/env bash
API_URL="<API_URL>"
API_KEY="<your-api-key>"
API_SECRET="<your-api-secret>"
FLOW_ID="<your-flow-id>"
PERSON_ID="<your-person-id>"
### THE LINES BELOW DO NOT REQUIRE ANY MODIFICATIONS ###
API_PATH="/liveness2/session"
TIMESTAMP=$(date +%s)
SIGNABLE_STR=$(echo -n -e "$TIMESTAMP$API_PATH")
HMAC_DIGEST=$(echo -n "$SIGNABLE_STR" | openssl sha256 -hmac "$API_SECRET" | cut -d' ' -f2)
DATA_JSON=$(cat <<-EOF
{
"person_id": "$PERSON_ID",
"flow_id": "$FLOW_ID"
}
EOF
)
curl -i -X POST "https://$API_URL$API_PATH" \
-H "Content-Type: application/json" \
-H "X-Verigram-Api-Version: 2.0" \
-H "X-Verigram-Api-Key: $API_KEY" \
-H "X-Verigram-Hmac-SHA256: $HMAC_DIGEST" \
-H "X-Verigram-Ts: $TIMESTAMP" \
-d "$DATA_JSON"
The endpoint returns a JSON object containing the following fields:
session_idaccess_tokenperson_idflow_id
2. Start the SDK
import 'package:verilive_sdk/verilive_sdk.dart';
final result = await VeriliveSdk.startLiveness(
VeriliveParams(
baseUrl: 'https://your-api.example.com',
personId: 'personId',
accessToken: 'your_access_token',
flowId: 'your_flow_id',
sessionId: 'your_session_id',
),
);
3. Handle the result
if (result.success) {
// Liveness verification passed
} else {
final code = result.errorCode;
}
API Reference
VeriliveSdk.startLiveness(VeriliveParams) → Future
Opens the native liveness verification screen. The call is suspended until the verification is completed, cancelled by the user, or terminated due to an error.
The method returns a VeriliveResult in all cases.
VeriliveParams
Parameters used to start the flow. Implements Parcelable.
data class VeriliveParams(
val baseUrl: String,
val personId: String,
val accessToken: String,
val flowId: String,
val sessionId: String,
val attemptsLeft: Int? = null,
) : Parcelable
Fields
baseUrl: String— Base API URL. An empty string ("") uses the default endpoint. For an on-premises deployment, specify the URL of your installation.personId: String— Identifier of the user undergoing verification.accessToken: String— Access token received from the backend.flowId: String— Flow identifier.sessionId: String— Identifier of the current session or attempt.attemptsLeft: Int?— Optional. Number of remaining attempts. The default value isnull.
VeriliveResult
The result returned after the flow is completed.
data class VeriliveResult(
val success: Boolean,
val errorCode: String?,
val errorMessage: String?,
)
Fields
success: Boolean—trueif the liveness verification passed;falsein all other cases, including verification failure, cancellation, or an error.errorCode: String?— Error code intended for programmatic handling. See Error Codes. The value isnullwhensuccess == true.errorMessage: String?— Human-readable error description. The value isnullwhensuccess == true.
Error Handling
Errors are returned in VeriliveResult. Use errorCode for programmatic handling and errorMessage for displaying a message to the user.
|
| Meaning |
|---|---|---|
|
| Verification passed |
|
| Liveness verification failed |
|
| Backend error |
|
| Network connection error |
|
| The user tapped Back or cancelled the verification |
|
| Internal SDK error |
Error Codes
Code | Description |
|---|---|
| Liveness verification failed: the face was not confirmed as live. |
| The backend returned an error during verification. |
| A network connection error prevented the verification from being completed. |
| The user cancelled the verification by tapping Back. |
| An internal SDK error occurred. |
