项目作者: devapro

项目描述 :
Biometric Authentication for android app
高级语言: Kotlin
项目地址: git://github.com/devapro/biometric.git
创建时间: 2020-08-04T09:30:43Z
项目社区:https://github.com/devapro/biometric

开源协议:

下载


Biometric-Auth

Add Biometric Authentication to any Android app

This library based on https://github.com/anitaa1990/Biometric-Auth-Sample. It is kotlin version with some improvements.

This library provides an easy way to implement fingerprint authentication without having to deal with all the boilerplate stuff going on inside.

API




How to integrate the library in your app?


Gradle Dependecy


gradle dependencies { implementation 'pro.devapp.biometric:biometric:1.0.0' }

Usage

  1. val dialogV23: BiometricDialogV23Interface = ....
  2. BiometricManager(
  3. this@MainActivity,
  4. "Title",
  5. "Subtitle example",
  6. "Description example",
  7. "Cancel",
  8. "Error text",
  9. dialogV23
  10. ).authenticate(biometricCallback)

The BiometricDialogV23Interface interface for dialog to support devices before BiometricPrompt. You can found implementation in example app

The BiometricCallback class has the following callback methods:

  1. BiometricCallback {
  2. override fun onSdkVersionNotSupported() {
  3. /*
  4. * Will be called if the device sdk version does not support Biometric authentication
  5. */
  6. }
  7. override fun onBiometricAuthenticationNotSupported() {
  8. /*
  9. * Will be called if the device does not contain any fingerprint sensors
  10. */
  11. }
  12. override fun onBiometricAuthenticationNotAvailable() {
  13. /*
  14. * The device does not have any biometrics registered in the device.
  15. */
  16. }
  17. override fun onBiometricAuthenticationPermissionNotGranted() {
  18. /*
  19. * android.permission.USE_BIOMETRIC permission is not granted to the app
  20. */
  21. }
  22. override fun onBiometricAuthenticationInternalError(error: String) {
  23. /*
  24. * This method is called if one of the fields such as the title, subtitle,
  25. * description or the negative button text is empty
  26. */
  27. }
  28. override fun onAuthenticationFailed() {
  29. /*
  30. * When the fingerprint doesn’t match with any of the fingerprints registered on the device,
  31. * then this callback will be triggered.
  32. */
  33. }
  34. override fun onAuthenticationCancelled() {
  35. /*
  36. * The authentication is cancelled by the user.
  37. */
  38. }
  39. override fun onAuthenticationSuccessful() {
  40. /*
  41. * When the fingerprint is has been successfully matched with one of the fingerprints
  42. * registered on the device, then this callback will be triggered.
  43. */
  44. }
  45. override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
  46. /*
  47. * This method is called when a non-fatal error has occurred during the authentication
  48. * process. The callback will be provided with an help code to identify the cause of the
  49. * error, along with a help message.
  50. */
  51. }
  52. override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
  53. /*
  54. * When an unrecoverable error has been encountered and the authentication process has
  55. * completed without success, then this callback will be triggered. The callback is provided
  56. * with an error code to identify the cause of the error, along with the error message.
  57. */
  58. }
  59. })