Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of 'doCancel' method for iOS #211

Open
jacobira opened this issue May 23, 2022 · 1 comment
Open

Addition of 'doCancel' method for iOS #211

jacobira opened this issue May 23, 2022 · 1 comment

Comments

@jacobira
Copy link

jacobira commented May 23, 2022

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-fingerprint-scanner@6.0.0 for the project I'm working on.

Added code to make a method available on iOS that cancels an ongoing biometric authentication process.

Here is the diff that solved my problem:

new file mode 100644
index 0000000..e69de29
diff --git a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.h b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.h
index 6afbca6..23e7e52 100644
--- a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.h
+++ b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.h
@@ -5,6 +5,8 @@
 #endif
 #import <LocalAuthentication/LocalAuthentication.h>
 
+#import <React/RCTBridgeModule.h>
+
 @interface ReactNativeFingerprintScanner : NSObject <RCTBridgeModule>
-	- (NSString *_Nonnull)getBiometryType:(LAContext *_Nonnull)context;
+
 @end
diff --git a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
index e29bad7..a502a07 100644
--- a/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
+++ b/node_modules/react-native-fingerprint-scanner/ios/ReactNativeFingerprintScanner.m
@@ -8,11 +8,21 @@
 
 @implementation ReactNativeFingerprintScanner
 
+static LAContext *context;
+
 RCT_EXPORT_MODULE();
 
+RCT_EXPORT_METHOD(doCancel)
+{
+    if(context != nil){
+        [context invalidate];
+    }
+}
+
 RCT_EXPORT_METHOD(isSensorAvailable: (RCTResponseSenderBlock)callback)
 {
-    LAContext *context = [[LAContext alloc] init];
+    context = [[LAContext alloc] init];
+    
     NSError *error;
 
     if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
@@ -57,7 +67,11 @@ @implementation ReactNativeFingerprintScanner
                   fallback: (BOOL)fallbackEnabled
                   callback: (RCTResponseSenderBlock)callback)
 {
-    LAContext *context = [[LAContext alloc] init];
+    if(context != nil){
+        [context invalidate];
+    }
+    context = [[LAContext alloc] init];
+    
     NSError *error;
 
     // Toggle fallback button
diff --git a/node_modules/react-native-fingerprint-scanner/src/.DS_Store b/node_modules/react-native-fingerprint-scanner/src/.DS_Store
new file mode 100644
index 0000000..d2c4feb
Binary files /dev/null and b/node_modules/react-native-fingerprint-scanner/src/.DS_Store differ
diff --git a/node_modules/react-native-fingerprint-scanner/src/doCancel.ios.js b/node_modules/react-native-fingerprint-scanner/src/doCancel.ios.js
new file mode 100644
index 0000000..ef3f0c7
--- /dev/null
+++ b/node_modules/react-native-fingerprint-scanner/src/doCancel.ios.js
@@ -0,0 +1,7 @@
+import { NativeModules } from "react-native";
+
+const { ReactNativeFingerprintScanner } = NativeModules;
+
+export default () => {
+    ReactNativeFingerprintScanner.doCancel();
+}
\ No newline at end of file
diff --git a/node_modules/react-native-fingerprint-scanner/src/index.js b/node_modules/react-native-fingerprint-scanner/src/index.js
index 3fc84b5..875a90e 100644
--- a/node_modules/react-native-fingerprint-scanner/src/index.js
+++ b/node_modules/react-native-fingerprint-scanner/src/index.js
@@ -1,9 +1,11 @@
 import authenticate from './authenticate';
 import isSensorAvailable from './isSensorAvailable';
 import release from './release';
+import doCancel from './doCancel.ios';
 
 export default {
   authenticate,
   release,
   isSensorAvailable,
+  doCancel,
 };

This issue body was partially generated by patch-package.

@BraveEvidence
Copy link

Check my video https://www.youtube.com/watch?v=DAZJ2JhDkNU. It will help you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants