Addition of 'doCancel' method for iOS
Opened this issue ยท 1 comments
jacobira commented
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 commented
Check my video https://www.youtube.com/watch?v=DAZJ2JhDkNU. It will help you