pub struct LAContext { /* private fields */ }
Expand description
Binding to LAContext
of LocalAuthentication
A mechanism for evaluating authentication policies and access controls.
§Overview
You use an authentication context to evaluate the user’s identity, either with biometrics like Touch ID or Face ID, or by supplying the device passcode. The context handles user interaction, and also interfaces to the Secure Enclave, the underlying hardware element that manages biometric data. You create and configure the context, and ask it to carry out the authentication. You then receive an asynchronous callback, which provides an indication of authentication success or failure, and an error instance that explains the reason for a failure, if any.
§Important
Include the NSFaceIDUsageDescription key in your app’s Info.plist file if your app allows biometric authentication. Otherwise, authorization requests may fail.
Implementations§
Source§impl LAContext
impl LAContext
Sourcepub fn set_localized_cancel_title(&mut self, title: &str)
pub fn set_localized_cancel_title(&mut self, title: &str)
set localizedCancelTitle
property.
The localized title for the cancel button in the dialog presented to the user during authentication.
§Discussion
The system presents a cancel button during biometric authentication to let the user abort the authentication attempt. The button appears every time the system asks the user to present a finger registered with Touch ID. For Face ID, the button only appears if authentication fails and the user is prompted to try again. Either way, the user can stop trying to authenticate by tapping the button.
Use the localizedCancelTitle property to choose a title for the cancel button. If you set the property to nil—as it is by default—or assign an empty string, the system uses an appropriate default title, like “Cancel”. Otherwise, provide a localized string that’s short and clear.
Sourcepub fn can_evaluate_policy(&self, policy: LAPolicy) -> bool
pub fn can_evaluate_policy(&self, policy: LAPolicy) -> bool
Assesses whether authentication can proceed for a given policy.