Аутентификация по отпечаткам пальцев с использованием react-native-fingerpirnt-scanner

#react-native #fingerprint

#react-native #отпечаток пальца

Вопрос:

Я использую react-native-fingerpirnt-scanner, библиотека работает нормально, я просто хотел спросить, можем ли мы иметь собственный модальный способ аутентификации по отпечаткам пальцев и добавить прослушиватель отпечатков пальцев к нашему собственному модальному?

 class BiometricPopup extends Component {
 ....

 componentDidMount() {
if (this.requiresLegacyAuthentication()) {
  this.authLegacy();
} else {
  this.authCurrent();
}
}

componentWillUnmount = () => {
FingerprintScanner.release();
}

requiresLegacyAuthentication() {
return Platform.Version < 23;
}

authCurrent() {
FingerprintScanner
  .authenticate({ title: 'Log in with Biometrics' })
  .then(() => {
    this.props.onAuthenticate();
  });
 }

authLegacy() {
FingerprintScanner
  .authenticate({ onAttempt: this.handleAuthenticationAttemptedLegacy })
  .then(() => {
   ...
  })
 ....
}

handleAuthenticationAttemptedLegacy = (error) => {
...
};

renderLegacy() {
const { errorMessageLegacy, biometricLegacy } = this.state;
const { style, handlePopupDismissedLegacy } = this.props;

return (
  <View style={styles.container}>
    <View style={[styles.contentContainer, style]}>
    ...
    </View>
  </View>
);
}

render = () => {
if (this.requiresLegacyAuthentication()) {
  return this.renderLegacy();
 }

// current API UI provided by native BiometricPrompt
return null;
}
}
 

Если кто-нибудь создал пользовательский модальный и связанный с ним отпечаток пальца, пожалуйста, поделитесь своим кодом. Спасибо