【问题标题】:How to implement face recognition authentication in React-native?React-native中如何实现人脸识别认证?
【发布时间】:2021-01-25 08:49:36
【问题描述】:

我是 React Native 的新手。我想在我的应用程序中实现人脸 id 和触摸 id 身份验证。在我的应用程序中,触摸 id 正在工作。但是面部识别码不起作用。我的面部身份验证代码如下:

 callFinger(isLogin) {
    TouchID.isSupported()
        .then(biometryType => {

            if (biometryType === 'TouchID') {

                TouchID.authenticate('Unlock with your fingerprint').then(success => {
                    if (success) {
                        if (isLogin == "true")
                            this.callRedirect(isLogin);
                        else
                            this.callLoginApi();
                    }
                }
                );
            } else if (biometryType === 'FaceID') {
                 TouchID.authenticate('Unlock with your FaceID').then(success => {
                    if (success) {
                        if (isLogin == "true")
                            this.callRedirect(isLogin);
                        else
                            this.callLoginApi();
                    }
                }
                );
            } else if (biometryType === true) {

                TouchID.authenticate('Unlock with your fingerprint').then(success => {
                    if (success) {
                        if (isLogin == "true")
                            this.callRedirect(isLogin);
                        else
                            this.callLoginApi();
                    }
                }
                );
            }
            else {
                this.callRedirect(isLogin);
            }
        })
        .catch(error => {
            this.callRedirect(isLogin);
        })

}

我正在将此链接用于触摸 ID,它对我有用。但在此链接中,面部识别码不起作用。 https://www.npmjs.com/package/react-native-touch-id

我也参考了下面的链接,但它也不起作用。 https://github.com/naoufal/react-native-touch-id/blob/master/examples/BiometricAuthExample/App.js

【问题讨论】:

    标签: ios react-native authentication authorization


    【解决方案1】:

    您可能已经有了解决方案,但如果其他人面临同样的问题......

    尝试在您的ios/<YourPoject>/info.plist 中添加这对键/字符串

    <key>NSFaceIDUsageDescription</key>
    <string>Enabling Face ID allows you quick and secure access to your account.</string>
    

    【讨论】:

      最近更新 更多