javascript 如何将指纹(Touch ID)添加到React-Native应用程序?

v6ylcynt  于 2023-08-02  发布在  Java
关注(0)|答案(3)|浏览(107)

我还没有找到使用React-Native的Touch ID解决方案。我只能使用在设备中注册的手指登录应用程序,但我如何才能实际注册一个新的手指,仅用于对该应用程序进行身份验证?

ar7v8xwq

ar7v8xwq1#

当然,在React Native库的背后,有Android/iOS原生代码。并且在这两种情况下,给定的设备API允许开发人员使用指纹保存的数据来进行认证。您无法获取指纹数据并将其保存在应用程序或服务器上。有关详细信息,请参阅this post
因此,由于原生端的限制,React Native无法获取指纹数据。

这是不可能的

ht4b089n

ht4b089n2#

//this is for checking suppport of face id and touch id on your device
        TouchID.isSupported()
              .then(biometryType => {
                // Success code
                if (biometryType === 'FaceID') {
                  console.log('FaceID is supported.');
                } else if (biometryType === 'TouchID'){
                  console.log('TouchID is supported.');
                } else if (biometryType === true) {
                  // Touch ID is supported on Android
            }
              })
              .catch(error => {
                // Failure code if the user's device does not have touchID or faceID 
                console.log(error);
              });
   // this is for applying touch id
    TouchID.isSupported()
      .then(authenticate)
      .catch(error => {
        AlertIOS.alert('TouchID not supported');
      });

字符串

rslzwgfq

rslzwgfq3#

import TouchID from 'react-native-touch-id';


const optionalConfigObject = {
      title: 'Authentication Required', // Android
      color: 'ffffff', // Android,
      fallbackLabel: 'Show Passcode', // iOS (if empty, then label is hidden)
    };


TouchID.isSupported()
      .then(biometryType => {
        // Success code
        if (biometryType === 'FaceID') {
          console.log('FaceID is supported.');
        } else {
          console.log('TouchID is supported.');
          TouchID.authenticate('Authenticate', optionalConfigObject)
            .then(success => {
              Alert.alert('Authenticated Successfully');
            })
            .catch(error => {
              Alert.alert('Authentication Failed', error.toString());
            });
        }
      })
      .catch(error => {
        // Failure code
        Alert.alert('No TouchId and FaceId Detected in this device');
      });

字符串
就这样享受你的编程…

相关问题