Implementing device lock–based user authentication

This commit is contained in:
mansi-dev
2026-01-14 23:57:48 +05:30
parent 1723d072aa
commit 250f9286d6
3 changed files with 29 additions and 0 deletions

10
package-lock.json generated
View File

@@ -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",

View File

@@ -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": {

View File

@@ -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');
}
};