From 5f9f643a47368a8051aa2d42b2aa9d3b82667ee0 Mon Sep 17 00:00:00 2001 From: noumantahir Date: Thu, 16 May 2024 18:48:23 +0500 Subject: [PATCH] migrated to use expo/localauth package instead of fingerprint-scanner --- ios/Podfile.lock | 6 ++++++ package.json | 1 + .../pinCode/container/pinCodeContainer.tsx | 15 +++++++++------ yarn.lock | 7 +++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a9c31534a..b693f6b2a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -40,6 +40,8 @@ PODS: - SDWebImageWebPCoder (~> 0.13.0) - ExpoKeepAwake (12.8.2): - ExpoModulesCore + - ExpoLocalAuthentication (13.8.0): + - ExpoModulesCore - ExpoModulesCore (1.11.10): - glog - RCT-Folly (= 2022.05.16.00) @@ -1446,6 +1448,7 @@ DEPENDENCIES: - ExpoFileSystem (from `../node_modules/expo-file-system/ios`) - ExpoImage (from `../node_modules/expo-image/ios`) - ExpoKeepAwake (from `../node_modules/expo-keep-awake/ios`) + - ExpoLocalAuthentication (from `../node_modules/expo-local-authentication/ios`) - ExpoModulesCore (from `../node_modules/expo-modules-core`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) @@ -1635,6 +1638,8 @@ EXTERNAL SOURCES: :path: "../node_modules/expo-image/ios" ExpoKeepAwake: :path: "../node_modules/expo-keep-awake/ios" + ExpoLocalAuthentication: + :path: "../node_modules/expo-local-authentication/ios" ExpoModulesCore: :path: "../node_modules/expo-modules-core" FBLazyVector: @@ -1842,6 +1847,7 @@ SPEC CHECKSUMS: ExpoFileSystem: eecaf6796aed0f4dd20042dc2ca2cac6c4bc1185 ExpoImage: 8cf2d51de3d03b7e984e9b0ba8f19c0c22057001 ExpoKeepAwake: 0f5cad99603a3268e50af9a6eb8b76d0d9ac956c + ExpoLocalAuthentication: c55ffb179683efed04cb144fc80ccf26891f0cb4 ExpoModulesCore: b2ae7a3fc6193556273c5db90065fbe7e11c7a60 FBLazyVector: fbc4957d9aa695250b55d879c1d86f79d7e69ab4 FBReactNativeSpec: 86de768f89901ef6ed3207cd686362189d64ac88 diff --git a/package.json b/package.json index cb549cfcb..91f0df0e1 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "events": "^1.0.0", "expo": "^50.0.8", "expo-image": "~1.10.6", + "expo-local-authentication": "~13.8.0", "hive-uri": "^0.2.5", "hivesigner": "^3.3.4", "https-browserify": "~0.0.0", diff --git a/src/screens/pinCode/container/pinCodeContainer.tsx b/src/screens/pinCode/container/pinCodeContainer.tsx index 6a6e5002b..977924ebc 100644 --- a/src/screens/pinCode/container/pinCodeContainer.tsx +++ b/src/screens/pinCode/container/pinCodeContainer.tsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { injectIntl } from 'react-intl'; import Config from 'react-native-config'; import get from 'lodash/get'; -import FingerprintScanner from 'react-native-fingerprint-scanner'; +import * as LocalAuthentication from 'expo-local-authentication'; // Actions & Services import { useNavigation } from '@react-navigation/native'; @@ -83,12 +83,15 @@ class PinCodeContainer extends Component { return; } - const biometryType = await FingerprintScanner.isSensorAvailable(); + + const biometryType = await LocalAuthentication.hasHardwareAsync() + console.log('biometryType is => ', biometryType); - await FingerprintScanner.authenticate({ - description: intl.formatMessage({ id: 'pincode.biometric_desc' }), - }); + await LocalAuthentication.authenticateAsync({ + promptMessage:intl.formatMessage({ id: 'pincode.biometric_desc' }) + }) + console.log('successfully passed biometric auth'); // code gets here means biometeric succeeded @@ -101,7 +104,7 @@ class PinCodeContainer extends Component { console.warn('Failed to process biometric', err); } - FingerprintScanner.release(); + LocalAuthentication.cancelAuthenticate(); }; // this function updates realm with appropriate master key required for encyrption diff --git a/yarn.lock b/yarn.lock index 7fb043d78..4b8818f5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6738,6 +6738,13 @@ expo-keep-awake@~12.8.2: resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-12.8.2.tgz#6cfdf8ad02b5fa130f99d4a1eb98e459d5b4332e" integrity sha512-uiQdGbSX24Pt8nGbnmBtrKq6xL/Tm3+DuDRGBk/3ZE/HlizzNosGRIufIMJ/4B4FRw4dw8KU81h2RLuTjbay6g== +expo-local-authentication@~13.8.0: + version "13.8.0" + resolved "https://registry.yarnpkg.com/expo-local-authentication/-/expo-local-authentication-13.8.0.tgz#21d9870bbaff0804325bd70f171273560a4293bb" + integrity sha512-h0YA7grVdo3834AS70EUCsalaXrrEnoq+yTvIhRTxiPmzWxUv7rNo5ff+XsIEYNElKPmT/wh/xPV1yo3l3fhGg== + dependencies: + invariant "^2.2.4" + expo-modules-autolinking@1.10.3: version "1.10.3" resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-1.10.3.tgz#19f349884a90f3f27ec9d64e8f2fa6be609558c5"