如何在 React-Native 中检查 Touch ID、Face Id、密码和模式锁定的支持 [英] How to check support of Touch ID, Face Id ,Password and pattern lock in React-Native
问题描述
我已经实现了一个 react-native-fingerprint-scanner
,它适用于 Touch Id
.
现在我想为两个平台的Touch ID、Face Id、Passcode 添加身份验证
有什么方法可以检查您的设备是否支持.另外,我尝试使用 react-native-touch-id
但它不适用于 Face Id
在 android 上.
有没有办法在两个平台(iOS/Android)上实现这一点?
参考:
react-native-touch-id
应该适用于 TouchID 和 FaceID.
如果 faceid/touch 不可用,iOS 允许设备回退到使用密码.这并不意味着如果前几次 touchid/faceid 失败,它将恢复为密码,而是如果前者未注册,则它将使用密码.
您可以先查看是否支持.
const optionalConfigObject = {fallbackLabel: '显示密码',密码回退:真,}TouchID.isSupported(optionalConfigObject).then(biometryType => {//成功代码if (biometryType === 'FaceID') {console.log('支持 FaceID.');} 别的 {console.log('支持TouchID.');}}).catch(错误=> {//失败代码控制台日志(错误);});
I have implemented a react-native-fingerprint-scanner
, it's working for Touch Id
.
Now I wanted to add authentication for Touch ID, Face Id, Passcode for both platform
Is there any way to check whether your device support or not. Also, I have tried using react-native-touch-id
but it is not for Face Id
on android.
Is there any way to achieve this for both platforms (iOS/Android)?
Reference:Link
react-native-touch-id
should work for both TouchID and FaceID.
iOS allows the device to fall back to using the passcode, if faceid/touch is not available. this does not mean that if touchid/faceid fails the first few times it will revert to passcode, rather that if the former are not enrolled, then it will use the passcode.
You can check to see if its supported first.
const optionalConfigObject = {
fallbackLabel: 'Show Passcode',
passcodeFallback: true,
}
TouchID.isSupported(optionalConfigObject)
.then(biometryType => {
// Success code
if (biometryType === 'FaceID') {
console.log('FaceID is supported.');
} else {
console.log('TouchID is supported.');
}
})
.catch(error => {
// Failure code
console.log(error);
});
这篇关于如何在 React-Native 中检查 Touch ID、Face Id、密码和模式锁定的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!