以下 内容中 设备指 移动设备
1. 检查设备可用的认证方式
uni.checkIsSupportSoterAuthentication({
success(res) {
uni.showModal({
content: '支持的认证方式:' + res.supportMode,
showCancel: false
});
console.log(res);
},
fail(err) {
console.log(err);
}
});
2. 检查设备是否录入指纹 -- fingerPrint
uni.checkIsSoterEnrolledInDevice({
checkAuthMode: 'fingerPrint',
success(res) {
if (res.isEnrolled) {
uni.showToast({
icon: 'none',
title: '已录入指纹'
});
} else {
uni.showModal({
content: '未录入指纹',
showCancel: false
});
}
console.log(res);
},
fail(err) {
uni.showModal({
content: '未录入指纹',
showCancel: false
});
console.log(err);
}
});
3. 检查设备是否录入面部识别 -- FaceID
uni.checkIsSoterEnrolledInDevice({
checkAuthMode: 'facial',
success(res) {
if (res.isEnrolled) {
uni.showToast({
icon: 'none',
title: '已录入FaceID'
});
} else {
uni.showModal({
content: '未录入FaceID',
showCancel: false
});
}
console.log(res);
},
fail(err) {
uni.showModal({
content: '未录入FaceID',
showCancel: false
});
console.log(err);
}
});
4. 使用指纹认证 -- fingerPrint
uni.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: '请用指纹解锁',
success(res) {
uni.showToast({
icon: 'none',
title: '指纹验证成功'
});
console.log(res);
},
fail(err) {
uni.showModal({
content: '指纹验证失败,errCode:' + err.errCode,
showCancel: false
});
console.log(err);
}
});
5. 使用面部识别认证 -- FaceID
uni.startSoterAuthentication({
requestAuthModes: ['facial'],
challenge: '123456',
authContent: '请用FaceID解锁',
success(res) {
uni.showToast({
icon: 'none',
title: 'FaceID验证成功'
});
console.log(res);
},
fail(err) {
uni.showModal({
content: 'FaceID验证失败,errCode:' + err.errCode,
showCancel: false
});
console.log(err);
}
});