EkycID Flutter SDK

一个易于使用的SDK,用于开发KYC流程的身份验证。使用此SDK,开发人员可以快速将KYC流程集成到他们的Flutter应用程序中。

此Flutter SDK是我们原生SDK(Android & iOS)的包装器。

1. 要求

iOS

  • 最低 iOS 部署目标:10.0
  • Xcode 13 或更高版本
  • Swift 5
  • EkycID仅支持64位架构(x86_64和arm64)。

Android

  • minSdkVersion: 21
  • targetSdkVersion: 32
  • compileSdkVersion 32

2. 安装

2.1. Flutter 设置

要使用此插件,请将ekyc_id_flutter添加为pubspec.yaml文件中的依赖项。

dependencies:
  ...
  ekyc_id_flutter:

2.2 iOS 设置

步骤 1: 在iOS上,将以下内容添加到Info.plist中

<!-- Camera Access -->
<key>NSCameraUsageDescription</key>
<string>Camera Access for Scanning</string>

<!-- Microphone Access -->
<key>NSMicrophoneUsageDescription</key>
<string>Microphone for playing instructions audio.</string>

步骤 2: 转到项目 > Runner > Building Settings > Excluded Architectures > Any SDK > armv7

步骤 3: 如下所示对Podfile进行调整。

# add this line:
$iOSVersion = '10.0'

post_install do |installer|
  # add these lines:
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
  end
  
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    
    # add these lines:
    target.build_configurations.each do |config|
      if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
      end
    end
    
  end
end

2.3. Android 设置

无需额外设置。

3. 用法

步骤 1: 设置服务器URL。

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  EkycIDServices.instance.setURL("YOUR_SERVER_URL");
  runApp(MyApp());
}

步骤 2: 设置EkycIDExpress小部件

我们提供了一个易于使用的小部件,名为EkycIDExpress。它为您处理了身份文件扫描和活体检测的逻辑。您只需要提供一个简单的回调来处理结果。以下是如何使用它。

class HomeScreen extends StatefulWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {

  Future<void> onKYCCompleted({
    required LivenessDetectionResult liveness,
    required DocumentScannerResult mainSide,
    DocumentScannerResult? secondarySide,
  }) async {
    print("== ACCESS RESULTS HERE ==");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TextButton(
          onPressed: () async {
            await showCupertinoModalBottomSheet(
              context: context,
              builder: (BuildContext context) {
                return EkycIDExpress(
                  language: Language.KH,
                  onKYCCompleted: onKYCCompleted,
                );
              },
            );
          },
          child: Text("Start KYC"),
        ),
      ),
    );
  }
}

步骤 3: 处理结果

onKYCCompleted回调中,您将可以访问LivenessDetectionResult的实例,以及两个DocumentScannerResult的实例(每个文档一面一个)。

步骤 3: 匹配人脸

您可以如下执行文档中的人脸与活体检测中的人脸之间的面部比较。

Future<void> onKYCCompleted({
  required LivenessDetectionResult liveness,
  required DocumentScannerResult mainSide,
  DocumentScannerResult? secondarySide,
}) async {
  
  ApiResult response = await EkycIDServices.instance.faceCompare(
    faceImage1: mainSide.faceImage,
    faceImage2: liveness.frontFace?.image,
  );

  print(response.data?) // match score
}

步骤 4: 执行OCR

您可以如下对文档图像执行OCR。

Future<void> onKYCCompleted({
  required LivenessDetectionResult liveness,
  required DocumentScannerResult mainSide,
  DocumentScannerResult? secondarySide,
}) async {
  
  ApiResult response = await EkycIDServices.instance.ocr(
    image: mainSide.documentImage,
    objectType: mainSide.documentType
  );

  print(response.data?) // response object based on document type
}

4. 许可证

© 2022 EKYC Solutions Co, Ltd. 版权所有。

GitHub

查看 Github