我正在使用该库对人脸识别或指纹扫描仪等生物识别传感器进行身份验证,但我想知道如何检测设备是否具有传感器:react-native-fingerprint-scanner
根据它的文档,有一个名为.isSensorAvailable()
的API,但是如果设备中没有可用的传感器,我不明白它会返回什么。
您可以像下面的示例一样使用.isSensorAvailable()
API。
import FingerprintScanner from 'react-native-fingerprint-scanner'
FingerprintScanner
.isSensorAvailable()
.then(() => {
// Call the Fingerprint Scanner Method
FingerprintScanner
.authenticate({ description: 'Authenticate to access this' })
.then(() => {
// Method for Authentication
onAuthenticate()
})
// Call error method
.catch(error => onAuthenticationFailure(error))
})
//Call the error method
.catch(error => onAuthenticationFailure(error))