Summary
LocalAuthentication.authenticateAsync() return false response in some time in Android.
while using the “USE PASSWORD” option, after entering the correct password will get the below response in some time.
{“message”:“Authentication cancelled”,“error”:“user_cancel”,“success”:false}
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
Bare React Native
Environment
Expo CLI 4.3.2 environment info:
System:
OS: macOS 10.15.7
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.21.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.11 - /usr/local/bin/npm
Managers:
CocoaPods: 1.10.1 - /Users/jaico/.rvm/gems/ruby-2.6.5/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 23, 24, 25, 27, 28, 29
Build Tools: 29.0.0, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0
System Images: android-27 Google Play Intel x86 Atom, android-29 Google APIs Intel x86 Atom
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.7042882
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
npmPackages:
react: 16.13.1 => 16.13.1
react-native: 0.63.4 => 0.63.4
npmGlobalPackages:
expo-cli: 4.3.2
Expo Workflow: bare
Reproducible demo or steps to reproduce from a blank project
scanFingerPrint = async () => {
try {
console.log(‘Before calling’)
let results = await LocalAuthentication.authenticateAsync({});
console.log(‘after calling’,JSON.stringify(results))
if (results.success) {
this.props.navigation.replace(‘Home’);
} else {
if (results.error === ‘user_cancel’) {
console.log(‘user cancel inside’)
setTimeout(() => {
Alert.alert(
‘Authenticate the user !’,
‘Authentication is necessary to login to the App. Please try again’,
[
{
text: ‘Login’,
onPress: () => {
let isLoggedIn = this.props.isLoggedIn;
if (isLoggedIn) {
this.scanFingerPrint();
}
},
},
],
);
}, 100);
console.log(‘After’)
}else{
console.log(‘user cancel else’)
}
}
} catch (e) {
console.log(e);
}
};
after completing the device compatibility check, I am calling the ‘scanFingerPrint’ method. In any case, if the user press cancel, then I will show the alert and if they press “Login” will call the same method.