pub struct Prompt { /* private fields */ }Expand description
What a person is asked to do, and how the dialog may let them do it.
Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn new(reason: impl Into<String>) -> Self
pub fn new(reason: impl Into<String>) -> Self
A prompt that explains, in the person’s language, why the app asks. The text is shown in
the system dialog: as the reason under the Face ID glyph on Apple platforms, the title of
the Android sheet, the message of the Windows Hello window, the title of the HarmonyOS
dialog. An empty reason is rejected with BiometricError::InvalidPrompt, because Apple
aborts on one and the others show a blank dialog. Localize it with res::str.
Sourcepub fn fallback_title(self, title: impl Into<String>) -> Self
pub fn fallback_title(self, title: impl Into<String>) -> Self
The label of the button that leads away from the biometric. With the device credential allowed it is the “use passcode” button (Apple), with it refused it is the negative button that dismisses the dialog (Android), and the platforms with no such button ignore it.
Sourcepub fn device_credential(self, allowed: bool) -> Self
pub fn device_credential(self, allowed: bool) -> Self
Whether the dialog offers the device credential (passcode, PIN, pattern, password) as a way
to pass. true by default, and what most apps want: a person whose finger is wet can still
get in. false asks for a biometric only; a device with none enrolled then fails with
BiometricError::NotEnrolled. Windows Hello decides this itself and ignores the flag.
Sourcepub fn challenge(self, challenge: impl Into<Vec<u8>>) -> Self
pub fn challenge(self, challenge: impl Into<Vec<u8>>) -> Self
Bytes the platform binds the result to. HarmonyOS issues an authentication token for the
challenge it is given (32 bytes at most) and a key bound to the same challenge accepts that
token once; day-part-keychain passes the challenge its keystore produced. Every other
platform ignores the challenge and returns an empty token.
Sourcepub fn fallback_title_text(&self) -> Option<&str>
pub fn fallback_title_text(&self) -> Option<&str>
The fallback button’s label, when one was given.
Sourcepub fn allows_device_credential(&self) -> bool
pub fn allows_device_credential(&self) -> bool
Whether the device credential may pass the prompt.
Sourcepub fn challenge_bytes(&self) -> &[u8] ⓘ
pub fn challenge_bytes(&self) -> &[u8] ⓘ
The challenge bytes, empty unless Prompt::challenge set them.