更新记录

1.0.20250825(2025-08-25)

  1. 实现IOS IsSupport / StartAuth 方法

1.0.20250814(2025-08-14)

  1. 持久化回调bug
  2. ios代码注释避免报错

1.0.20250813.1(2025-08-13)

  1. ios代码去除避免ios打包失败
查看更多

平台兼容性

uni-app(4.07)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x(4.08)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - - - -

引入插件

  • 点击插件试用引入到项目
  • 打包自定义基座包
  • 按照下方示例测试
  • 先插件试用,完全符合需求后购买

Andorid

import * as biometricUtils from '@/uni_modules/cms-biometric';

插件方法

方法 描述 参数
IsSupport() 是否支持生物识别(强生物/弱生物/中高设备凭据认证)
IsEnrolled() 是否录入生物识别(强生物/弱生物/中高设备凭据认证)
IsSupportForKey(string) 是否支持某种生物识别 strong:强生物 、 weak:弱生物 、credential:中高设备凭据认证
IsEnrolledForKey(string) 是否录入某种生物识别 strong:强生物 、 weak:弱生物 、credential:中高设备凭据认证
StartAuth(StartAuthOption) 开始认证 StartAuthOption 见下方
export type StartAuthOption = {
    // 标题
    title : string; 
    // 副标题
    subtitle : string;
    // 按钮文本
    negativeButtonText : string;
    // 使用某种生物识别,可空(空等同于["strong","weak","credential"])
    models ?: string[],
    // 成功回调
    success : () => void;
    // 失败回调
    fail : (errCode : number, errMsg : string) => void;

}

区别

  • 强生物认证解释: 3D结构光人脸识别、高精度指纹传感器、虹膜识别
  • 弱生物认证解释: 2D人脸识别(如普通摄像头)、基础指纹传感器
  • 中高设备凭据认证解释: PIN码、图案或密码
  • 不同机型代表可能不一致 真我Q3表现为,强生物代表指纹、弱生物代表面容、中高设备凭据认证代表密码

IOS

  • 本插件IOS版本仅实现了 IsSupport / StartAuth
  • StartAuth入参在IOS平台下仅title/success/fail 有效
  • IsSupportForKey/IsEnrolled/IsEnrolledForKey方法在IOS版本不实现直接返回true
  • IOS生物认证判断可参照官方API 链接

示例页面

<template>
    <view style="padding-top: 300rpx;">
        <button type="primary" @click="IsSupport">是否支持生物识别(下方任意一种)</button>
        <button type="primary" @click="IsSupportForKey('strong')">是否支持强生物识别</button>
        <button type="primary" @click="IsSupportForKey('weak')">是否支持弱生物识别</button>
        <button type="primary" @click="IsSupportForKey('credential')">是否支持中高设备凭据认证</button>
        <button type="primary" @click="IsEnrolled">是否录入生物识别</button>
        <button type="primary" @click="IsEnrolledForKey('strong')">是否录入强生物识别</button>
        <button type="primary" @click="IsEnrolledForKey('weak')">是否录入弱生物识别</button>
        <button type="primary" @click="IsEnrolledForKey('credential')">是否录入中高设备凭据认证</button>
        <button type="primary" @click="StartAuth">开始验证识别</button>

        <view>强生物认证解释: 3D结构光人脸识别、高精度指纹传感器、虹膜识别</view>
        <view>弱生物认证解释: 2D人脸识别(如普通摄像头)、基础指纹传感器</view>
        <view>中高设备凭据认证解释: PIN码、图案或密码</view>
        <view>IOS仅存在IsSupport/StartAuth两个方法,其他方法空实现默认返回true</view>

    </view>
</template>

<script>
    import * as biometricUtils from '@/uni_modules/cms-biometric';

    export default {
        data() {
            return {}
        },
        methods: {
            showModel(msg) {
                uni.showModal({
                    title: "提示",
                    showCancel: false,
                    content: msg
                })
            },
            IsSupport() {
                this.showModel(`${biometricUtils.IsSupport() ? '支持' : '不支持'}生物识别!`);
            },
            IsEnrolled() {
                this.showModel(`${biometricUtils.IsEnrolled() ? '已录入' : '未录入'}生物识别!`);
            },
            IsSupportForKey(key) {
                this.showModel(`${biometricUtils.IsSupportForKey(key) ? '支持' : '不支持'}${key}!`);
            },
            IsEnrolledForKey(key) {
                this.showModel(`${biometricUtils.IsEnrolledForKey(key) ? '已录入' : '未录入'}${key}!`)
            },
            StartAuth() {
                biometricUtils.StartAuth({
                    title: "我的title",
                    subtitle: "我的subtitle",
                    negativeButtonText: "我的确认",
                    models: ['strong', 'weak', 'credential'],
                    success: () => {
                        this.showModel(`验证成功`);
                    },
                    fail: (errCode, errMsg) => {
                        this.showModel(`验证失败:errCode:${errCode},errMsg:${errMsg}`);
                    }
                })
            }
        }
    }
</script>

需要帮助?有其他插件的需求?联系我!

隐私、权限声明

1. 本插件需要申请的系统权限列表:

<!-- 适配 Android 9.0+ --> <uses-permission android:name="android.permission.USE_BIOMETRIC" /> <!-- 适配 Android 6.0-8.1 --> <uses-permission android:name="android.permission.USE_FINGERPRINT" /> <!-- 启用设备密码验证 --> <uses-permission android:name="android.permission.USE_DEVICE_CREDENTIAL" />

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率: