更新记录
1.0.0(2025-06-05)
新增功能
- 新增了
checkAuth
,authLogin
方法 - 初始版本
问题修复
- 无
功能优化
- 无
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 6.0 | × | × |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | - | × | × | × | × |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 6.0 | × | × | × |
生物认证识别,支持人脸识别、指纹识别,用于用户登录 、支付、解锁认证等(ima-auth)
ima-auth
是一款生物认证识别的UTS插件,支持检测支持哪些生物识别
、认证识别
等功能,主要应用于人脸、指纹进行登录、支付、解锁认证等授权,使用手机本身自带的人脸、指纹进行识别,进而判断是否机主本人,从而进行授权验证
⚠️注意️
android 端
已全部完成代码的开发与测试(已完成)harmony 端
(计划中)
需要权限
- 文件读取、文件写入
"android.permission.USE_BIOMETRIC"
"android.permission.USE_FACE"
"android.permission.CAMERA"
"android.permission.USE_FINGERPRINT"
- 即:在
manifest.json
中的distribute.android.permissions
加入
// 生物识别
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
// 人脸识别
<uses-permission android:name="android.permission.USE_FACE" />
// 相机(人脸识别)
<uses-permission android:name="android.permission.CAMERA" />
// 指纹识别
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
使用示例【此示例只实现了所有的功能
逻辑】
- 新建一个
test.vue
的文件
<template>
<view class="content">
<!-- 生物识别登录 -->
<view class="content-title">生物识别登录</view>
<view class="content-message">
(生物识别登录包括人脸、指纹,⚠️注意:部分国内安卓厂商禁止使用人脸认证,只能调起指纹识别)
</view>
<view class="content-button auto-login" @click="onCheck">检测支持性</view>
<view class="content-button auto-login" @click="onStartAuth('biometric')">
人脸&指纹识别(biometric)
</view>
<view class="content-button auto-login" @click="onStartAuth('face')">人脸识别(face)</view>
<view class="content-button auto-login" @click="onStartAuth('finger')">指纹识别(finger)</view>
</view>
</template>
<script lang="ts">
import {checkAuth, authLogin, AuthType, AuthLoginResult} from "@/uni_modules/ima-auth";
export default {
data() {
return {};
},
onLoad() {
},
methods: {
// 检测支持性
onCheck() {
const list = checkAuth();
console.log("检测支持性", list);
},
// 开始识别操作
onStartAuth(type: AuthType) {
console.log("开始识别操作:", type);
authLogin(type, (res: AuthLoginResult) => {
console.log("登录结果", res);
});
}
}
};
</script>
<style lang="scss">
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&-title {
margin-top: 10rpx;
padding: 10rpx;
font-size: 44rpx;
font-weight: 800;
color: #ff0000;
}
&-message {
font-size: 28rpx;
font-weight: 800;
text-align: center;
color: #ff6700;
}
&-button {
height: 65rpx;
width: 750rpx;
padding: 20rpx;
line-height: 65rpx;
text-align: center;
background: #00e0f1;
margin-bottom: 25rpx;
}
}
</style>
方法
方法名称 | 说明 | 方法参数 | 平台 |
---|---|---|---|
checkAuth | 检测支持哪些生物识别 | 无 | android |
authLogin | 认证识别 | type : AuthType,要认证的类型,callback:回调函数 | android |