When integrating the Liveness SDK, you will need to provide the following parameters:
serviceBaseUrl
The endpoint where the liveness service is hosted.
• For Demo environments, use: https://d1.cynopsis.co/service
• For Production environments, use: https://util.cynopsis.co/service
accessToken
The authentication token required to access the SDK services.
Obtain your access token by referring to the Authentication section above.
domainId
Your unique domain identifier, provided by Cynopsis Solutions or your system administrator.
provider
The liveness provider version. Currently, set this to: V2
These parameters must be passed into the SDK initialization as shown in the integration examples below.
To start integrating the SDK with your application codebase, follow the sample code provided for your platform below. Each example shows how to initialize and configure the SDK using the required parameters, helping you get up and running quickly.
Ensure that "node_modules/@aws-amplify/ui-react/styles.css" appears before your custom styles in the styles array under the appropriate project’s build options.
<!-- Angular Example --><liveness-detector [serviceBaseUrl]="apiUrl" [domainId]="domainId" [accessToken]="accessToken" provider="V2" (liveness-ready)="onReady()" (liveness-result)="onResult($event)"></liveness-detector>
// In your Angular componentapiUrl = "YOUR_SERVICE_BASE_URL";domainId = "YOUR_DOMAIN_ID";accessToken = "YOUR_ACCESS_TOKEN";onReady() { // handle ready}onResult(result: any) { // handle result console.log(result);}
If your project uses custom code-splitting or defines manual chunks (such as in a Vite or Webpack config), make sure all react-cs-liveness dependencies are kept together in the same chunk. Incorrect configuration may cause runtime issues related to duplicate React instances or missing dependencies, especially when using React 18+ or advanced bundling.
We recommend not setting custom chunking rules for the SDK or to use our provided plugins (see below) to ensure correct bundling.
If you are not sure about your chunking setup, test your build to ensure the Liveness component loads and works as expected.
Click here for Vite setup instructions
If your project uses Vite, we strongly recommend using our official liveness() Vite plugin from react-cs-liveness/config.
This plugin ensures correct code-splitting and chunking for all react-cs-liveness dependencies, avoiding runtime errors (like React 18+ createRoot issues) that commonly occur when custom manualChunks are defined.For example, with a Vue project:
// vite.config.jsimport { defineConfig } from 'vite'import { liveness } from 'react-cs-liveness/config'export default defineConfig({ plugins: [ liveness({ mergeWithExisting: true, // Merge safely with your existing manualChunks }), ],})
This setup ensures react-cs-liveness and all its internal dependencies are correctly bundled—no matter your framework or chunking rules. The mergeWithExisting: true option integrates seamlessly with your app’s existing Vite code-splitting configuration.
Tested with Gradle 8.13.0:
The following configuration has been verified with Gradle 8.13.0.
// Enable core library desugaring in your build.gradleandroid { compileOptions { coreLibraryDesugaringEnabled true // other compile options if any }}dependencies { implementation project(path: ':liveness-release') implementation 'com.amplifyframework:core:2.30.1' implementation 'com.amplifyframework.ui:liveness:1.7.1' implementation 'androidx.compose.material3:material3:1.4.0' implementation 'androidx.compose.material:material-icons-extended:1.7.8' implementation 'com.amplifyframework:aws-auth-cognito:2.30.1' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'}
Implementing the Liveness SDK in Your Activity
Here’s a simple and practical example to get you quickly started with the Liveness SDK in your Android app:
// 1. Create LivenessTestConfig with your access token and service URLLivenessTestConfig config = new LivenessTestConfig( Provider.V2, "https://d1.cynopsis.co/service", 1L, // your domain ID "YOUR_ACCESS_TOKEN");// 2. Setup LivenessOnLoad callback to handle SDK ready or failure stateLivenessOnLoad livenessOnLoad = new LivenessOnLoad() { @Override public void succeed(String message) { // SDK initialized successfully setLivenessCustomization(); } @Override public void failed(String message) { // SDK initialization failed }};// Initialize the LivenessTestLivenessTest liveness = new LivenessTest(this, config, livenessOnLoad);// 3. Start liveness detection with custom delegate to receive resultsLivenessTestDelegate livenessTestDelegate = new LivenessTestDelegate() { @Override public void onResponse(LivenessTestResults response) { switch (response.getStatus()) { case PASSED: // Success: handle result break; case ERROR: case FAILED: // Handle error or failed attempt break; } }};liveness.startLiveness(livenessTestDelegate);// 4. Customization color (optional)private void setLivenessCustomization() { LivenessV2Customization customization = new LivenessV2Customization().getDefault(); customization.setBackground(0xFFf2e8cf); customization.setPrimary(0xffbc4749); customization.setOnPrimary(0xFFf2e8cf); customization.setOnBackground(0xffbc4749); LivenessTestV2GlobalState.setCustomization(customization);}
Tip: Replace "YOUR_ACCESS_TOKEN" with your real access token provided via onboarding, and make sure IDs like startButton, messageResult, messageStatus, and imageResult exist in your activity_main.xml.
This example will initialize the SDK, show status and liveness selfie results, and display passed/failed messages for your users.