Skip to content

Instantly share code, notes, and snippets.

@vinodbaste
Last active May 7, 2022 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinodbaste/bb37b1ca47fd5a353e1a1e65a981adc3 to your computer and use it in GitHub Desktop.
Save vinodbaste/bb37b1ca47fd5a353e1a1e65a981adc3 to your computer and use it in GitHub Desktop.
fun showBiometricPrompt(
title: String = "Biometric Authentication",
subtitle: String = "Enter biometric credentials to proceed.",
description: String = "Input your Fingerprint or FaceID to ensure it's you!",
activity: AppCompatActivity,
listener: BiometricAuthListener,
cryptoObject: BiometricPrompt.CryptoObject? = null,
allowDeviceCredential: Boolean = false
) {
// 1
val promptInfo = setBiometricPromptInfo(
title,
subtitle,
description,
allowDeviceCredential
)
// 2
val biometricPrompt = initBiometricPrompt(activity, listener)
// 3
biometricPrompt.apply {
if (CryptoObject == null) authenticate(promptInfo)
else authenticate(promptInfo, cryptoObject)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment