Bio Login with Backend V2
The Bio Login module supports multiple selfie capture methods for biometric authentication.
In all methods, the result must be uploaded to the backend for verification.
Basic Flow
The typical usage of the Bio Login module follows these steps:
-
Initialize the desired selfie capture type
- Choose between Manual Selfie Capture, Automatic Selfie Capture, or Pose Estimation based on your integration needs.
- Attach an observer to receive the captured selfie data (Bitmap).
-
Capture the selfie
- The module either automatically captures the image when the user is in the correct position or waits for the user to press a button.
- In the case of Pose Estimation, the module ensures the face/head pose meets the criteria before capturing.
-
Upload the captured selfie
- Call the upload method on the Bio Login module with the captured Bitmap.
- Provide a callback to handle the result of the upload (success/failure).
-
Handle post-upload actions
- Display success or error messages to the user.
- Remove the fragment from the UI if needed to maintain a clean navigation flow.
This basic flow ensures that the captured selfie is validated, uploaded, and monitored correctly across all capture methods.
Manual Selfie Capture
The user manually triggers selfie capture (e.g., by pressing a button).
val fragment = Amani.sharedInstance().BioLogin()
.ManualSelfieCapture()
.observer(object : ManualSelfieCaptureObserver {
override fun cb(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Auto Selfie Capture
Automatically captures the selfie when the user is in the correct position and lighting.
val fragment = Amani.sharedInstance().BioLogin()
.AutoSelfieCapture()
.observer(object : AutoSelfieCaptureObserver {
override fun cb(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Pose Estimation Capture
Captures selfie after verifying head/face pose.
val fragment = Amani.sharedInstance().BioLogin()
.PoseEstimation()
.observer(object : PoseEstimationObserver {
override fun onSuccess(bitmap: Bitmap?) {
bitmap?.let {
//Call the upload function
}
}
override fun onFailure(reason: OnFailurePoseEstimation, currentAttempt: Int) {
// Handle failure case
}
override fun onError(error: Error) {
// Handle error
}
})
.build()
fragment?.let {
navigateToFragmentMethod(it)
}
Upload
Uploads the captured selfie data to the backend for verification.
- Use the
uploadmethod provided by the Bio Login module. - Provide the current activity/context and a callback to handle the result.
- The callback receives a Boolean indicating success or failure of the BioLogin status.
Example
Amani.sharedInstance().BioLogin().upload(requireContext(),
object : BioLoginUploadCallBack {
override fun cb(result: Boolean?) {
// Handle upload result
Toast.makeText(
requireContext(),
if (result == true) "BioLogin successful" else "BioLogin failed",
Toast.LENGTH_LONG
).show()
}
}
)