From 250f9286d6a5860281554ac989b553d5817538d7 Mon Sep 17 00:00:00 2001 From: mansi-dev Date: Wed, 14 Jan 2026 23:57:48 +0530 Subject: [PATCH] =?UTF-8?q?Implementing=20device=20lock=E2=80=93based=20us?= =?UTF-8?q?er=20authentication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 10 ++++++++++ package.json | 1 + src/screen/GetPinAuthenticate.tsx | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/screen/GetPinAuthenticate.tsx diff --git a/package-lock.json b/package-lock.json index 216e344..7d7c1c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@react-native/new-app-screen": "0.83.1", "react": "19.2.0", "react-native": "0.83.1", + "react-native-biometrics": "^3.0.1", "react-native-safe-area-context": "^5.5.2" }, "devDependencies": { @@ -10101,6 +10102,15 @@ } } }, + "node_modules/react-native-biometrics": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/react-native-biometrics/-/react-native-biometrics-3.0.1.tgz", + "integrity": "sha512-Ru80gXRa9KG04sl5AB9HyjLjVbduhqZVjA+AiOSGqr+fNqCDmCu9y5WEksnjbnniNLmq1yGcw+qcLXmR1ddLDQ==", + "license": "MIT", + "peerDependencies": { + "react-native": ">=0.60.0" + } + }, "node_modules/react-native-safe-area-context": { "version": "5.6.2", "resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-5.6.2.tgz", diff --git a/package.json b/package.json index c1f3193..26db412 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@react-native/new-app-screen": "0.83.1", "react": "19.2.0", "react-native": "0.83.1", + "react-native-biometrics": "^3.0.1", "react-native-safe-area-context": "^5.5.2" }, "devDependencies": { diff --git a/src/screen/GetPinAuthenticate.tsx b/src/screen/GetPinAuthenticate.tsx new file mode 100644 index 0000000..31334d0 --- /dev/null +++ b/src/screen/GetPinAuthenticate.tsx @@ -0,0 +1,18 @@ + +import ReactNativeBiometrics from 'react-native-biometrics'; + +const rnBiometrics = new ReactNativeBiometrics({ + allowDeviceCredentials: true, // IMPORTANT +}); + +const authenticateWithDevicePin = async () => { + const { success } = await rnBiometrics.simplePrompt({ + promptMessage: 'Authenticate using device lock', + }); + + if (success) { + console.log('User authenticated using device PIN / Pattern / FaceID'); + } else { + console.log('Authentication cancelled'); + } +};