uniapp生物识别示例(人脸识别、指纹识别)

准备工作:

mainfest.json设置勾选:

勾选完成后打 App自定义调试基座测试包

示例代码:

html 复制代码
<template>
	<view class="content">
		<button v-if="supportSoterAuthenticationArray.includes('facial')" @click="SoterAuthenticationFunction('facial')">人脸识别</button>
		<button v-if="supportSoterAuthenticationArray.includes('fingerPrint')" @click="SoterAuthenticationFunction('fingerPrint')">指纹识别</button>
	</view>
</template>

<script setup>
	import { onShow } from '@dcloudio/uni-app'
	import { ref } from 'vue';
	
	onShow(()=>{
		checkIsSupportSoterAuthentication()
	})
	
	const supportSoterAuthenticationArray = ref([])
	const checkIsSupportSoterAuthentication = () => {
		uni.checkIsSupportSoterAuthentication({
			success(res) {
				supportSoterAuthenticationArray.value = res.supportMode
			}
		})
	}
	
	const SoterAuthenticationFunction = (type) => {
		uni.checkIsSoterEnrolledInDevice({
			checkAuthMode: type,
			success(res) {
				res.isEnrolled && uni.startSoterAuthentication({
					requestAuthModes: [type],
					challenge: '123456',
					authContent: '生物解锁',
					success(res) {
						console.log(res,'成功回调','执行相关逻辑');
					}
				})
			}
		})
	}
</script>

<style lang="scss" scoped>
	
</style>

效果展示:

相关推荐
2501_9151063215 小时前
当 Perfdog 开始收费之后,我重新整理了一替代方案
android·ios·小程序·https·uni-app·iphone·webview
2501_9159184118 小时前
中小团队发布,跨平台 iOS 上架,证书、描述文件创建管理,测试分发一体化方案
android·ios·小程序·https·uni-app·iphone·webview
家里有只小肥猫18 小时前
uniApp打包ios报错
ios·uni-app
jingling55520 小时前
uniapp | 基于高德地图实现位置选择功能(安卓端)
android·前端·javascript·uni-app
某公司摸鱼前端20 小时前
前端一键部署网站至服务器FTP
前端·javascript·uni-app
爱怪笑的小杰杰20 小时前
UniApp 桌面应用实现 Android 开机自启动(无原生插件版)
android·java·uni-app
m0_6470579620 小时前
uniapp使用rich-text流式 Markdown 换行问题与解决方案
前端·javascript·uni-app
木子啊21 小时前
Uni-app导航栏适配终极避坑指南
uni-app·自定义导航栏·导航栏
2501_9151063221 小时前
iOS 如何绕过 ATS 发送请求,iOS调试
android·ios·小程序·https·uni-app·iphone·webview
行走的陀螺仪1 天前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app