react-native-keychain
react-native-keychain copied to clipboard
Added fallback mechanism for android
authenticationType was not being respected on Android
- After going through the following link found out that there is a scope for adding support for fallback on Android API 30 & above.
- Updated the Example App to support the same.
Guys this is my first PR,
- it is showing as merging is blocked
- Some checks haven't completed yet.
I am not sure if I have to do anything more from my side.
If I run lint and flow locally I do not get any errors,
@gokulkulkarni1987 , I tried your solution but I got the following error
{"Authentication error is => ": {"error": [Error: Negative text must not be set if device credential authentication is allowed.]}}
I tested on two Android version 11 & 12
@gokulkulkarni1987 , I tried your solution but I got the following error
{"Authentication error is => ": {"error": [Error: Negative text must not be set if device credential authentication is allowed.]}}I tested on two Android version 11 & 12
I fixed this issue by adding authenticationPrompt: { cancel: '' } . Furthermore, it should be handled internally in KeychainModule.java at line # 622 .
ERROR => When I add the above line, I get the following error on devices ANDROID_VERSION < 11
{"Authentication error is => ": {"error": [Error: Negative text must be set and non-empty.]}}
Expected Behavior: It should be working on ANDROID_VERSION < 11. I don't have depth knowledge of ANDROID, But I figured out that if make some changes at line # 622 (Code of block is mentioned below). It should be resolved.
if (null != promptInfoOptionsMap && promptInfoOptionsMap.hasKey(AuthPromptOptions.CANCEL)) { String promptInfoNegativeButton = promptInfoOptionsMap.getString(AuthPromptOptions.CANCEL); promptInfoBuilder.setNegativeButtonText(promptInfoNegativeButton); }
@saadi-ninjasCode We get Negative text must be set and non-empty when just BIOMETRIC_STRONG is enabled.
The fix I have added is for supporting both BIOMETRIC_STRONG & DEVICE_CREDENTIAL, which is available only after Android API 30, for DEVICE_CREDENTIALS to work we must not set cancel text (thats internal of Android).
Below is the screenshot from class BiometricPrompt
if you see the lines from KeychainModule,
Negative button text setting or not is already handled, so on react-native side if we just check the android version and accordingly pass or not would be better idea.
