alive_flutter_plugin 0.0.2
alive_flutter_plugin: ^0.0.2 copied to clipboard

A new Flutter plugin.

Flutter Plugin Yidun Alive Detect #

易盾活体检测flutter原生插件版

活体接入 #

集成 #

在pubspec.yaml中添加

  dependencies:
    alive_flutter_plugin: ^xxx稳定版

配置依赖 #

在flutter工程对应的android/app/build.gradle 文件的android域中添加

  repositories {
          flatDir {
              dirs project(':alive_flutter_plugin').file('libs')
          }
      }

初始化 #

初始化要尽早

  final AliveFlutterPlugin aliveFlutterPlugin = new AliveFlutterPlugin(); // 初始化对象
  aliveFlutterPlugin.init("请输入您的业务id", “超时时间,单位秒”);

开始检测 #

   aliveFlutterPlugin.startLiveDetect().then((value) {
      /**
       * action表示返回的动作列表,动作状态表示:0——正面,1——右转,2——左转,3——张嘴,4——眨眼。
       */
      var actions = value["actions"];
      setState(() {
        this.action = actions;
        if (actions) {
          _result = "初始化成功$actions";
        } else {
          _result = "初始化失败$actions";
        }
      });
    });

动作类型映射 #

var actions = value["actions"]; {
    '0': '正视前方',
	'1': '向右转头',
	'2': '向左转头',
	'3': '张嘴动作',
	'4': '眨眼动作',
};

停止检测 #

  aliveFlutterPlugin.stopLiveDetect();

释放资源(Android特有) #

  aliveFlutterPlugin.destroy();

检测状态监听 #

   var eventChannel = const EventChannel("yd_alive_flutter_event_channel")
   eventChannel.receiveBroadcastStream().listen(_onData, onError: _onError);
   
   void _onData(response) {
    if (response is Map) {
      setState(() {
        var type = response["type"];
        if (type == "checking") {
          _currentStep = response["currentStep"];
          _result = response["message"];
        } else if (type == "checked") {
          _result = response["message"];
          _currentStep = 0;
          stopLive();
        } else if (type == "exception") {
          _result = response["message"];
        }
      });
    }
  }

iOS Quirks

  1. 易盾活体检测用到摄像头功能,请确保有摄像和网络权限
  2. 在工程的info.plist文件里设置相机权限
NSPhotoLibraryUsageDescriptionApp需要您的同意,才能访问相册NSCameraUsageDescriptionApp需要您的同意,才能访问相机
  1. 编译: 将引入SDK头文件的.m文件重命名为.mm文件 或者 在Xcode中找到TARGETS-->Build Setting-->Apple Clang - Language-->Compile Source As在这个选项中选择 Objective-C++

  2. ios编译需安装pod环境。配置好开发者账号即可编译

  3. app接入活体设置(如权限设置等)请参考易盾文档

Android Quirks

  1. 易盾活体检测用到摄像头功能,请确保有摄像和网络权限
  2. 需要ndk能力,请在local.properties中配置ndk.dir
  3. 预览高度不要随意设置,请遵守大部分相机支持的预览高宽比,3:4或9:16
  4. 如果想在android设置预览的容器形状,请修改preview_layout.xml
0
likes
65
pub points
0%
popularity

A new Flutter plugin.

Homepage

Documentation

API reference

License

LICENSE

Dependencies

flutter

More

Packages that depend on alive_flutter_plugin