Skip to content

Instantly share code, notes, and snippets.

@OkancanCosar
Created August 2, 2022 06:13
Show Gist options
  • Save OkancanCosar/74d49890552e90602a5712c242f7c12c to your computer and use it in GitHub Desktop.
Save OkancanCosar/74d49890552e90602a5712c242f7c12c to your computer and use it in GitHub Desktop.
LocalAuthentication with expo
...
expo > ios > infoPlist
"NSFaceIDUsageDescription": "This app use face id authentication."
...
import * as LocalAuthentication from 'expo-local-authentication'
useEffect(() => {
(async () => {
const compatible: boolean = await LocalAuthentication.hasHardwareAsync();
const savedBiometrics: boolean = await LocalAuthentication.isEnrolledAsync();
const biometricAuth: LocalAuthentication.LocalAuthenticationResult = await LocalAuthentication.authenticateAsync({
promptMessage: 'Login with Biometrics',
disableDeviceFallback: true,
cancelLabel: "cancel",
fallbackLabel: "fallback",
requireConfirmation: false
});
console.log("⚡️ ", {
compatible,
savedBiometrics,
biometricAuth,
});
})();
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment