Advanced Methods
These are useful methods that you can use in your app to fully support Biometrics and PIN.
To complete the functionalities, we provide the following methods:
Enable and Disable Biometric
Biometrics entries are unique per device. When the user disable their biometrics, their biometrics enrollment for that device will be deleted from the database. When they enable biometrics, they are essentially enrolling that device again for biometrics, and therefore they will be prompted to verify the biometrics again.
To do enable/disable biometrics, you have to initialize Cotter's biometrics prompt first using:
Generally, context
, fragmentActivity
, and activity
can be filled with this
inside your activity.
Here is a step-by-step guide on enabling and disabling Biometrics
1. Create a Callback
This callback will called when biometric is enabled or disabled.
cotterBiometricCallback
onSuccess
onSuccess
will be called when the biometric is successfully enabled or disabled.
If the user successfully disabled biometrics, we will call
onSuccess(false)
. Soenrolled = false
here, because biometrics is no longer enrolled.If the user successfully enabled biometrics, we will call
onSuccess(true)
.
onCanceled
onCanceled
will be called when the user try to enable biometrics, but they canceled the biometric prompt (dismissed the prompt).
onError
onError
will be caleld when an error occur while enabling or disabling biometrics.
2. Initialize Cotter Biometric
You have to initialize Cotter Biometric before using it to enable or disable
Example:
3. Enable Biometric
Remember, you have to initialize Cotter Biometric first before calling this function.
4. Disable Biometric
Remember, you have to initialize Cotter Biometric first before calling this function.
5. Checking the Enrolled status of Biometric after enable/disable
You can check again if the biometric is correctly enabled/disabled using the function below:
Check if Methods are Enrolled
You can check if an authentication method is enrolled and available for a user.
1. Check if Biometric is available
This method is used to check if biometric is available on the user's device. You need to provide a callback of type CotterMethodChecker
to handle the result.
Example:
2. Check if Biometrics is enrolled in the current device
This method is used to check if biometric is enrolled. You need to provide a callback of type CotterMethodChecker
to handle the result.
Example:
3. Check if Pin is enrolled
This method is used to check if pin is enrolled. You need to provide a callback of type CotterMethodChecker
to handle the result.
Example:
Change Pin
Starting the PinChange
flow is exactly the same as starting the PinEnrollment
flow.
Example:
Last updated