smallcase / react-native-simple-biometrics

simple interface to verify user authenticity
https://www.npmjs.com/package/react-native-simple-biometrics
MIT License
183 stars 16 forks source link

Option to disable Pin/Pattern #5

Open LonelyCpp opened 3 years ago

LonelyCpp commented 3 years ago

is there any possibility to hide the 'UsePin/UsePattern' form the prompt in android

Originally posted by @ndileep-dev in https://github.com/smallcase/react-native-simple-biometrics/issues/3#issuecomment-871886727

dcangulo commented 2 years ago

I use the following patch file to disable pin/pattern.

Filename: react-native-simple-biometrics+1.5.0.patch

diff --git a/node_modules/react-native-simple-biometrics/android/src/main/java/com/reactnativesimplebiometrics/SimpleBiometricsModule.java b/node_modules/react-native-simple-biometrics/android/src/main/java/com/reactnativesimplebiometrics/SimpleBiometricsModule.java
index d4c53a4..ab08598 100644
--- a/node_modules/react-native-simple-biometrics/android/src/main/java/com/reactnativesimplebiometrics/SimpleBiometricsModule.java
+++ b/node_modules/react-native-simple-biometrics/android/src/main/java/com/reactnativesimplebiometrics/SimpleBiometricsModule.java
@@ -23,8 +23,7 @@ public class SimpleBiometricsModule extends ReactContextBaseJavaModule {
     public static final String NAME = "SimpleBiometrics";

     static final int authenticators =  BiometricManager.Authenticators.BIOMETRIC_STRONG
-        | BiometricManager.Authenticators.BIOMETRIC_WEAK
-        | BiometricManager.Authenticators.DEVICE_CREDENTIAL;
+        | BiometricManager.Authenticators.BIOMETRIC_WEAK;

     public SimpleBiometricsModule(ReactApplicationContext reactContext) {
         super(reactContext);
@@ -82,6 +81,7 @@ public class SimpleBiometricsModule extends ReactContextBaseJavaModule {
                                         .setAllowedAuthenticators(authenticators)
                                         .setTitle(title)
                                         .setSubtitle(subtitle)
+                                        .setNegativeButtonText("Cancel")
                                         .build();

                                 prompt.authenticate(promptInfo);
diff --git a/node_modules/react-native-simple-biometrics/ios/SimpleBiometrics.mm b/node_modules/react-native-simple-biometrics/ios/SimpleBiometrics.mm
index 620c8ee..e91f895 100644
--- a/node_modules/react-native-simple-biometrics/ios/SimpleBiometrics.mm
+++ b/node_modules/react-native-simple-biometrics/ios/SimpleBiometrics.mm
@@ -33,10 +33,10 @@ @implementation SimpleBiometrics
 {

     dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        NSString *promptMessage = subtitle;
+        NSString *promptMessage = title;

         LAContext *context = [[LAContext alloc] init];
-        context.localizedFallbackTitle = title;
+        context.localizedFallbackTitle = @"";

         LAPolicy localAuthPolicy = LAPolicyDeviceOwnerAuthenticationWithBiometrics;
         if (![[UIDevice currentDevice].systemVersion hasPrefix:@"8."]) {
VariabileAleatoria commented 2 years ago

I agree this feature should be added