Skip to main content

Usage

Import Amani

import 'dart:io' show Platform;

import 'package:amani_flutter_sdk/amanisdk.dart';
import 'package:amani_flutter_sdk/sdkresult.dart'; // For SdkResult class.

Acquire profile token

If you dont know hot to get profile token you need to read acquire profile token documentation.

Calling startAmaniSDKWithToken

startAmaniSDKWithToken is the common SDK start method that can be used in standard Flutter integrations.

final _amanisdkPlugin = Amanisdk();

Future<void> startSDK() async {
SdkResult result = await _amanisdkPlugin.startAmaniSDKWithToken(
server: "server_url supplied from us.",
token: "profile token from the web server",
id: "id number",
);

print(result);
}

In the result, there will be general variables to check error states and whether the verification is completed.
If the user returns from the SDK screen, the result object will be filled accordingly.

Acquire profile token

If you do not know how to get a profile token, please read the Acquire Profile Token documentation.


Android-only Configure Usage

For Android integrations, you can configure the SDK before starting the KYC flow by using setConfigure.

This approach is useful when you want to:

  • Configure the SDK once before launching the KYC flow.
  • Enable only the required Android dynamic features.
  • Reduce unnecessary first-load time.
  • Prepare your integration for the newer Android SDK configuration flow.
Android only

setConfigure and startAmaniSDKWithConfigure are intended for Android usage.

For iOS or simple cross-platform usage, you can continue using startAmaniSDKWithToken.

Dynamic Features

Dynamic features are modular Android SDK components that can be initialized on demand instead of always being bundled in the base flow.

Selecting only the features required by your use case can help reduce unnecessary initialization time.

FeatureDescription
idCaptureEnables ID document scanning and capture
idHologramDetectionEnables hologram detection on the ID document
nfcScanEnables NFC chip reading for supported documents
selfieAutoEnables automatic selfie capture
selfiePoseEstimationEnables selfie liveness detection with pose estimation
note

If you do not specify enabledFeatures, all available features may be enabled by default.

For better performance, we recommend enabling only the features required by your verification flow.


Usecase 1: Basic Android Configure

Use this when you want to configure the Android SDK with a server URL and explicitly selected dynamic features.

final _amanisdkPlugin = Amanisdk();

Future<void> startAndroidSDKWithConfigure() async {
if (Platform.isAndroid) {
await _amanisdkPlugin.setConfigure(
server: "https://server.example",
enabledFeatures: const [
AmaniAndroidDynamicFeature.idCapture,
AmaniAndroidDynamicFeature.idHologramDetection,
AmaniAndroidDynamicFeature.nfcScan,
AmaniAndroidDynamicFeature.selfieAuto,
AmaniAndroidDynamicFeature.selfiePoseEstimation,
],
);

SdkResult result = await _amanisdkPlugin.startAmaniSDKWithConfigure(
token: "profile token from the web server",
id: "id number",
lang: "tr",
);

print(result);
}
}

In this use case:

  • setConfigure configures the Android SDK before the KYC flow starts.
  • server is passed during the configure step.
  • startAmaniSDKWithConfigure starts the KYC flow with the profile token and user ID.
  • enabledFeatures defines which Android dynamic modules should be used.

Usecase 2: Configure Only Required Features

If your flow does not require every SDK module, you should enable only the necessary dynamic features.

For example, if your flow only requires ID capture and selfie verification:

final _amanisdkPlugin = Amanisdk();

Future<void> startAndroidSDKWithSelectedFeatures() async {
if (Platform.isAndroid) {
await _amanisdkPlugin.setConfigure(
server: "https://server.example",
enabledFeatures: const [
AmaniAndroidDynamicFeature.idCapture,
AmaniAndroidDynamicFeature.selfieAuto,
],
);

SdkResult result = await _amanisdkPlugin.startAmaniSDKWithConfigure(
token: "profile token from the web server",
id: "id number",
lang: "en",
);

print(result);
}
}

This is recommended when your verification flow does not use NFC, hologram detection, or pose estimation.


Optional Parameters

Depending on your integration and SDK version, Android configure flow can also support additional security and upload configuration options.

Shared Secret

sharedSecret is used to sign and validate network requests.

  • This value will be provided confidentially by the Amani team.
  • If it is not provided, the SDK can still work.
  • However, upload requests may be unsigned.
  • For production environments, using sharedSecret is recommended when available.

Upload Source

uploadSource is used to distinguish uploads from different sources.

Common upload source values are:

  • KYC
  • VIDEO
  • PASSWORD

If not specified, the default upload source is usually KYC.

SSL Pinning

SSL Pinning provides additional network security by validating SSL certificates.

For Android native integrations, SSL Pinning should be configured before SDK configuration.
If your Flutter SDK version exposes SSL Pinning through the Flutter plugin, call it before setConfigure.

warning

If an invalid SSL certificate is provided, the SDK may throw an exception. Always handle SSL Pinning configuration with proper error handling.


Android Configure Flow Summary

The Android configure flow should follow this order:

if (Platform.isAndroid) {
// 1. Configure the SDK first
await _amanisdkPlugin.setConfigure(
server: "https://server.example",
enabledFeatures: const [
AmaniAndroidDynamicFeature.idCapture,
AmaniAndroidDynamicFeature.selfieAuto,
],
);

// 2. Start the KYC flow
SdkResult result = await _amanisdkPlugin.startAmaniSDKWithConfigure(
token: "profile token from the web server",
id: "id number",
lang: "tr",
);

// 3. Read the SDK result
print(result);
}
caution

startAmaniSDKWithConfigure should be called after setConfigure.

If the SDK is started without being configured first, the Android SDK may fail because the required configuration has not been initialized.


Which Start Method Should I Use?

Use caseRecommended method
Standard Flutter integrationstartAmaniSDKWithToken
iOS integrationstartAmaniSDKWithToken
Android integration with dynamic feature controlsetConfigure + startAmaniSDKWithConfigure
Android integration where only selected modules are neededsetConfigure + startAmaniSDKWithConfigure

For most simple integrations, startAmaniSDKWithToken is enough.

For Android integrations where you want more control over dynamic features and initialization behavior, use the configure flow.