ID Verification provides a Flutter plugin that lets you add eKYC remote identity verification to your Flutter app. This topic walks through the integration process with sample code.
Limits
-
The SDK does not support emulators. Use a physical device for development and debugging.
-
System requirements: iOS 9.0 or later and Android 5.0 or later.
Configure dependencies
-
Go to Client SDK release notes to download and extract the Flutter SDK.
-
Copy the entire Flutter SDK folder to your project.

-
In your project's pubspec.yaml, add the Alibaba Cloud plugin dependency under dev_dependencies.
aliyun_face_plugin: path: aliyun_face_plugin
Configure the Android environment
Add module dependencies
In your project's android > build.gradle file, add flatDir to the allprojects field.
flatDir {
dirs project(':aliyun_face_plugin').file('libs')
}

Configure Proguard obfuscation rules
If you use Proguard for code obfuscation in release builds, add the following rules to android > app > proguard-rules.pro:
-verbose
-keep class com.idv.identity.platform.api.** {*;}
-keep class com.idv.identity.platform.log.** {*;}
-keep class com.idv.identity.util.IdentityUtils {*;}
-keep class com.idv.identity.ocr.IdentityOcrApi {*;}
-keep class com.idv.identity.platform.model.** {*;}
-keep class com.idv.identity.platform.config.** {*;}
-keep class com.idv.identity.face.IdentityFaceApi {*;}
-keep class com.face.verify.intl.** {*;}
-keep class com.alibaba.fastjson.** {*;}
-keep class face.security.device.api.** {*;}
-keep class net.security.device.api.** {*;}
-keep class com.dtf.toyger.** { *; }
-dontwarn net.security.device.api.**
-dontwarn face.security.device.api.**
-keep class com.idv.identity.service.algorithm.** {*;}
-keep class com.idv.identity.base.algorithm.** {*;}
-keep class com.idv.identity.quality.QualityRouter {*;}
-keep class com.idv.identity.blink.BlinkRouter {*;}
-keep class com.idv.identity.service.IdentityFaceService {*;}
-keep class com.idv.identity.service.ocr.IdentityDocService {*;}
-keep class com.alibaba.sdk.android.oss.** { *; }
-dontwarn okio.**
-dontwarn org.apache.commons.codec.binary.**
# NFC
-keep class com.idv.identity.nfc.IdentityNfcApi { *; }
-keep class org.jmrtd.** {*;}
-keep class net.sf.**{*;}
-keep class org.**{*;}
-keep class cn.**{*;}
# Please add these rules to your existing keep rules to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.fasterxml.**
-dontwarn com.google.**
-dontwarn java.applet.Applet
-dontwarn java.awt.**
-dontwarn javax.**
-dontwarn org.**
-dontwarn retrofit2.**
-dontwarn springfox.documentation.spring.web.json.Json
# Optional: Log obfuscation
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
Configure the iOS environment
Add camera permissions
-
Go to iOS > Runner.xcworkspace to open the Runner project in Xcode.
-
Add camera permissions to the Info.plist file of the Runner project. Customize the Value as needed.

Add bundles
Go to Runner > Build Phases > Copy Bundle Resources and add the following four bundles.
These bundles are located in the aliyun_face_plugin/ios/Products directory, each inside its corresponding framework folder.
-
ToygerService.bundle: Located in ToygerService.framework.
-
AliyunIdentityPlatform.bundle: Located in AliyunIdentityPlatform.framework.
-
AliyunIdentityOCR.bundle: Located in AliyunIdentityOCR.framework.
-
AliyunIdentityFace.bundle: Located in AliyunIdentityFace.framework.

Add the -ObjC linker flag
Go to Pods and click Build Settings. Under Linking, add -ObjC to Other Linker Flags.

API reference
The Flutter SDK provides four operations: initWithOptions, getMetaInfos, verify, and setCustomUI.
class AliyunFacePlugin {
// Initializes the SDK.
Future<void> init() {
return AliyunFacePluginPlatform.instance.init();
}
// Initializes the SDK with options.
Future<void> initWithOptions(Map<String, String> options) {
return AliyunFacePluginPlatform.instance.initWithOptions(options);
}
// Gets the metainfos of the client. The metainfos are used to obtain the transaction ID from the server.
Future<String?> getMetaInfos() {
return AliyunFacePluginPlatform.instance.getMetaInfos();
}
// Starts the verification process.
Future<String?> verify(Map<String, String> params) {
return AliyunFacePluginPlatform.instance.verify(params);
}
// Customizes the UI.
Future<String?> setCustomUI(String configuration) {
return AliyunFacePluginPlatform.instance.setCustomUI(configuration);
}
}
Initialize the SDK
Call initWithOptions(options) during app cold start, as early as possible after the user accepts the privacy policy.
The options parameter, which is null by default, specifies optional data collection settings.
The ID Verification client includes a built-in security module known as the device helper. The device helper provides various data reporting regions to meet local data collection compliance requirements. You can set
CustomUrlandCustomHostto specify different reporting sites based on user attributes.Only one data reporting region can be specified per application session lifecycle. The region for server-side queries must match the reporting region. The supported regions vary by product. For more information, see Supported regions.
For each region, the
CustomUrlis as follows:China (Hong Kong):
https://cloudauth-device.cn-hongkong.aliyuncs.comSingapore:
https://cloudauth-device.ap-southeast-1.aliyuncs.comIndonesia (Jakarta):
https://cloudauth-device.ap-southeast-5.aliyuncs.comUS (Silicon Valley):
https://cloudauth-device.us-west-1.aliyuncs.comGermany (Frankfurt):
https://cloudauth-device.eu-central-1.aliyuncs.comMalaysia (Kuala Lumpur):
https://cloudauth-device.ap-southeast-3.aliyuncs.com
Parameter | Description | Example |
IPv6 | Indicates whether to use an IPv6 domain name to report device information:
| "1" |
DataSwitch | Controls when to report device information:
Note The default setting is recommended. | "1" |
CustomUrl | Sets the server domain name for data reporting. | |
CustomHost | Sets the server host for data reporting. | "cloudauth-device.ap-southeast-1.aliyuncs.com" Note This example is for the Singapore region. For server hosts in other regions, see CustomUrl for each region. |
Get MetaInfos
getMetaInfos() returns the client environment context. Pass this value to your server, which then uses it to request a transactionId from Alibaba Cloud.
Start verification
Call verify() to start a verification request.
-
Parameters of the verify() operation:
-
Required parameter: transactionId
-
Optional parameters:
-
-
Return value: a comma-separated string in the format
code,reason, wherecodeis the error code andreasonis the error description.The
codeandreasonvalues differ between iOS and Android. For more information, see the platform-specific SDK documentation.
Call setCustomUI() to customize the UI colors:
-
Parameter:
params(JSON format). UI customization options are documented in the native SDKs:
Each transactionId can be used only once. Reuse causes the following errors:
-
iOS: 2002: ZIM network failure.
-
Android: 1001, NET_RESPONSE_INVALID.
Sample code
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:aliyun_face_plugin/aliyun_face_plugin.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _infos = 'Unknown';
final _aliyunFacePlugin = AliyunFacePlugin();
@override
void initState() {
super.initState();
// Call the init operation early in the app startup process.
Map<String, String> options = {"CustomUrl":"https://cloudauth-device.ap-southeast-5.aliyuncs.com",
"CustomHost":"cloudauth-device.ap-southeast-5.aliyuncs.com"};
_aliyunFacePlugin.initWithOptions(options);
}
Future<void> getMetaInfos() async {
String metainfos;
try {
// Get the client metainfos. Send the information to the server to call the relevant server-side API operations and obtain the transaction ID.
metainfos = await _aliyunFacePlugin.getMetaInfos() ?? 'Unknown metainfos';
} on PlatformException {
metainfos = 'Failed to get metainfos.';
}
setState(() {
_infos = "metainfos: " + metainfos;
});
}
Future<void> setCustomUi() async {
try {
String config = "{\"faceConfig\":{ \"faceBGColor\": \"#FF33FF\"}}";
await _aliyunFacePlugin.setCustomUI(config) ?? '-1,error';
} on PlatformException {
'-2,exception';
}
}
Future<void> startVerify() async {
String verifyResult;
try {
String transactionId = "xxxx"; // The transaction ID.
Map<String, String> params = {
"transactionId": transactionId,
};
if (Platform.isIOS) {
params.addAll({"kIdentityParamKeyLanguage": "en"});
} else if (Platform.isAndroid) {
params.addAll({"SdkLanguage": "en"});
}
verifyResult = await _aliyunFacePlugin.verify(params) ?? '-1,error';
} on PlatformException {
verifyResult = '-2,exception';
}
setState(() {
_infos = "verifyResult: " + verifyResult;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Aliyun face plugin demo')),
body: Center(
child: Column(children: <Widget>[
Text('$_infos\n'),
ElevatedButton(
onPressed: () async {
getMetaInfos();
},
child: Text("getMetaInfos")),
ElevatedButton(
onPressed: () async {
startVerify();
},
child: Text("startVerify")),
ElevatedButton(
onPressed: () async {
setCustomUi();
},
child: Text("setCutomUi")),
])),
),
);
}
}
Go to Client SDK release notes to download the Flutter demo and view the complete code.
This demo is for reference only. Use the latest SDK version in your project.