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>

效果展示:

相关推荐
阿奇__3 小时前
uniapp支付宝 H5 开发踩坑,hash模式下取参要规范!
开发语言·uni-app
云起SAAS6 小时前
小智笔记APP源码 | 8大广告联盟聚合(穿山甲/优量汇/快手/百度) | 应用市场过审极速版 | uni-app全栈商用项目
笔记·uni-app·广告联盟·笔记app
蹦哒8 小时前
UniApp 原生插件开发完整指南
uni-app
a_Ichuan8 小时前
在HBuilderX创建的uniapp项目中使用unocss
前端·uni-app
web前端神器9 小时前
记录uniapp小程序的报错
小程序·uni-app·apache
yqcoder11 小时前
uni-app 之 网络请求
网络·uni-app
克里斯蒂亚诺更新11 小时前
uniapp适配H5和Android-apk实现获取当前位置经纬度并调用接口
android·前端·uni-app
2501_916008891 天前
深入解析iOS应用启动性能优化策略与实践
android·ios·性能优化·小程序·uni-app·cocoa·iphone
巴巴博一1 天前
uni-app 踩坑实录:实现“可拖拽全局悬浮按钮”时的 movable-view 坐标失效与 Flex 布局视错觉
vue.js·uni-app
阿奇__1 天前
h5微信授权code失效排查过程及解决记录
微信·uni-app