Having trouble enabling Biometric authentication in my project using react-native-touch-id on a real device. I've added the key and description in info.plist and followed all the steps mentioned in the official docs of the library. If anyone is familiar with this, your help would be greatly appreciated.
import React, {useEffect, useState} from 'react';
import {BackHandler, StatusBar, StyleSheet} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import TouchID from 'react-native-touch-id';
import {Provider} from 'react-redux';P
import RouteHome from './src/navigation';
import store from './src/redux/store';
export default function App() {
const [isAuth, setIsAuth] = useState(false);
const optionalConfigObject = {
title: 'Authentication Required',
imageColor: '#e00606',
imageErrorColor: '#ff0000',
sensorDescription: 'Touch sensor',
sensorErrorDescription: 'Failed',
cancelText: 'Cancel',
fallbackLabel: 'Show Passcode',
unifiedErrors: false,
passcodeFallback: false,
};
useEffect(() => {
handleBiometric();
});
const handleBiometric = () => {
TouchID.isSupported(optionalConfigObject).then(biometryType => {
if (biometryType === 'FaceID') {
console.log('FaceID is supported.');
} else {
if(isAuth) {
return null;
}
TouchID.authenticate('', optionalConfigObject).then((success) => {
setIsAuth(success)
}).catch((err) => {
BackHandler.exitApp();
})
}
});
};
return (
<Provider store={store}>
<SafeAreaView>
<StatusBar barStyle="light-content" />
<RouteHome />
</SafeAreaView>
</Provider>
);
}