Skip to main content

Installation

You will receive an API key and a Client ID from SmartComply. Keep these secure and do not commit them to source control.
Add the SDK to your app’s pubspec.yaml, replacing YOUR_TOKEN with the token provided to you:
dependencies:
  smartcomply_sdk:
    git:
      url: https://YOUR_TOKEN@github.com/Anitajallas/smartcomply-web-sdk.git
      path: flutter
Then run:
flutter pub get
Store the git token in an environment variable or a secrets manager — never hard-code it in pubspec.yaml.

How It Works

1

Create Session

Your app calls createSession() using your apiKey and clientId. This returns a session token.
POST /v1/session/create
2

Verify Identity

Your app calls onboarding.verify() using the session token to confirm the user’s identity.
POST /v1/onboarding/verify
3

Liveness Check

Your app calls liveness.startCheck():
  1. On-device AI: Camera opens and ML Kit detects face actions locally (no network).
  2. Autoshot capture: An autoshot is captured and sent to receive an Entry ID.
    POST /v1/liveness/create
    
  3. Video upload: The video is uploaded for final analysis.
    POST /v1/liveness/submit
    
Face detection runs entirely on-device — no video is streamed live to the server.

Platform Setup

In android/app/src/main/AndroidManifest.xml, add inside <manifest>:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
In android/app/build.gradle (or build.gradle.kts):
android {
    defaultConfig {
        minSdk 21
    }
}

Initialisation

import 'package:smartcomply_sdk/smartcomply_sdk.dart';

final sdk = SmartComply(
  SDKConfig(
    apiKey: 'YOUR_API_KEY',        // Bearer token from SmartComply
    clientId: 'YOUR_CLIENT_UUID',  // UUID from your SmartComply dashboard
    environment: Environment.production,
  ),
);
ParameterRequiredDescription
apiKeyAPI key issued by SmartComply. Used to authenticate session creation.
clientIdUUID of your SDK config record. Ties the session to your account settings.
environmentOptionalControls which SmartComply backend the SDK connects to:
Environment.production - Live system. Verifications use real databases and charge your account.
Environment.sandbox - Testing system. Uses mock data and does not charge your account.
Defaults to sandbox.
timeoutOptionalHTTP timeout. Defaults to 15 seconds.

Step 1 — Create a Session

final session = await sdk.createSession();
print(session.token); // UUID session token
Must be called before any other SDK method. All subsequent calls automatically use the session token.

Step 2 — Verify Identity

// Verify BVN
final result = await sdk.onboarding.verify(
  onboardingType: OnboardingType.bvn,
  idNumber: '22476562817',
);

// Verify NIN
final result = await sdk.onboarding.verify(
  onboardingType: OnboardingType.nin,
  idNumber: '91014204738',
);

if (result.isVerified) {
  print('Verified at: ${result.verifiedAt}');
}
OnboardingTypeID
OnboardingType.bvnBank Verification Number
OnboardingType.ninNational Identification Number

Step 3 — Liveness Check

Opens the camera full-screen, guides the user through actions, captures a photo and video, and submits both to the backend:
final result = await sdk.liveness.startCheck(
  context,
  identifier: '22476562817',     // user's ID number
  identifierType: 'bvn',         // 'bvn' or 'nin'
  country: 'nigeria',
  challengeActions: [
    ChallengeAction.blink,
    ChallengeAction.turnLeft,
  ],
);

print('Status: ${result.status}');           // "success"
print('Liveness: ${result.livenessStatus}'); // "processing" → "passed" | "failed"

Supported Challenge Actions

ChallengeActionAPI value sentDetection method
ChallengeAction.blinkBLINKML Kit eye open probability
ChallengeAction.turnLeftTURN_LEFTML Kit head euler Y angle
ChallengeAction.turnRightTURN_RIGHTML Kit head euler Y angle
ChallengeAction.turnHeadTURN_HEADML Kit head euler Y angle (either direction)
ChallengeAction.openMouthOPEN_MOUTHHeuristic (confirmed by backend video AI)
After liveness/submit, the status will be "processing" while the backend AI analyses the video. The final passed or failed status is delivered via webhook to your webhook_url.

Error Handling

try {
  await sdk.createSession();
} on SDKError catch (e) {
  print('Error ${e.statusCode}: ${e.message}');
}

Full Example

import 'package:flutter/material.dart';
import 'package:smartcomply_sdk/smartcomply_sdk.dart';

final sdk = SmartComply(
  SDKConfig(
    apiKey: 'YOUR_API_KEY',
    clientId: 'YOUR_CLIENT_UUID',
    environment: Environment.production,
  ),
);

Future<void> runVerification(BuildContext context) async {
  try {
    // 1. Session
    await sdk.createSession();

    // 2. Identity
    final identity = await sdk.onboarding.verify(
      onboardingType: OnboardingType.bvn,
      idNumber: '22476562817',
    );
    if (!identity.isVerified) return;

    // 3. Liveness
    final liveness = await sdk.liveness.startCheck(
      context,
      identifier: '22476562817',
      identifierType: 'bvn',
      country: 'nigeria',
      challengeActions: [ChallengeAction.blink, ChallengeAction.turnLeft],
    );

    print('Liveness submitted: ${liveness.status}');
    // Final result delivered via webhook
  } on SDKError catch (e) {
    debugPrint('SmartComply error: $e');
  }
}