Biometrics
Usage
- Add JitPack to your project build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency in the application build.gradle
dependencies {
implementation "com.github.FunkyMuse.KAHelpers:biometrics:$utilsVersion"
}
- Add necessary permissions
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
//if you're using the legacy FingerprintController
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
- Example
canAuthenticate(hardwareUnavailable = {
//some message about hardware missing
}, noFingerprintsEnrolled = {
//make user action to enroll fingerprints
}) {
biometricAuth(promptInfoAction = {
setTitle("Verification required")
setSubtitle("Action paused")
setDescription("Please verify your identity to proceed with the action")
setDeviceCredentialAllowed(true)
this
}, onAuthFailed = {
//auth failed action
}, onAuthError = { errorCode, errorMessage ->
//handle auth error message and codes
}) {
//handle successful authentication
}
}