One.LocalAuthentication evaluates Apple’s biometric policy. Call it from a
user action and give the system a clear reason to display.
import { One } from 'one'
const status = One.LocalAuthentication.canEvaluatePolicy()if (status.available) { const authenticated = await One.LocalAuthentication.evaluatePolicy( 'Unlock your saved account' ) if (authenticated) { // continue to the protected action }}Set the Face ID usage text in the app manifest before prebuilding:
native: { app: { ios: { bundleId: 'com.example.app', faceIdUsageDescription: 'Unlock your saved account with Face ID.', }, },}canEvaluatePolicy() returns { available, biometryType, errorCode? }.
biometryType is none, touchID, faceID, or opticID. Availability is
false when biometrics are not enrolled or are unavailable. errorCode is the
Apple LAError numeric code when the policy cannot be evaluated.
evaluatePolicy(reason) resolves true after authentication and false when
the user or system cancels. An empty reason rejects with E_LOCAL_AUTH_REASON;
a binary without the Face ID usage text rejects with E_LOCAL_AUTH_MANIFEST.
Unavailable biometrics reject with E_LOCAL_AUTH_NOT_ENROLLED,
E_LOCAL_AUTH_LOCKOUT, or E_LOCAL_AUTH_PASSCODE_NOT_SET when applicable.
Other failures reject with E_LOCAL_AUTH_FAILED. The error’s code property
holds that value. This API uses biometrics only and hides the passcode fallback
button. Biometric authentication is implemented on iOS and Android. On Android errorCode is the BiometricManager result code, and biometryType reports touchID or faceID only when exactly one enrolled kind is provable; zero or ambiguous kinds report none. There is no Android manifest code because biometric use is an install-time permission. Web reports { available: false, biometryType: 'none' }; evaluatePolicy() rejects with LocalAuthentication.evaluatePolicy needs an iOS or Android build, so authentication never succeeds without native support.
Edit this page on GitHub.