如何检查设备是否具有用于生物特征识别的传感器? (react-native-fingerprint-scanner)

问题描述 投票:0回答:1

我正在使用该库对人脸识别或指纹扫描仪等生物识别传感器进行身份验证,但我想知道如何检测设备是否具有传感器:react-native-fingerprint-scanner

根据它的文档,有一个名为.isSensorAvailable()的API,但是如果设备中没有可用的传感器,我不明白它会返回什么。

react-native fingerprint biometrics touch-id face-id
1个回答
0
投票

您可以像下面的示例一样使用.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))
© www.soinside.com 2019 - 2024. All rights reserved.