You will simply need to call:
ConfigFile.startBioLogin(activity, resultLauncherLogin, true)
The registerForActivityResult collects the return logic of the login, you can perform actions either if it was wrong or successful and save the user token or collect the user information in case it was requested (see next paragraph).
The last parameter is a Boolean that allows you to collect, directly, the user information at the end of the login.
resultLauncherLogin = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){ result ->
if (result.resultCode == Activity.RESULT_OK) {
result.data?.extras?.let {
val token = it.get(Constants.TOKEN) as TokenResponse
if (it.get(USER_INFO) != null) {
onSuccess(it.get(USER_INFO) as UserInfoBack)
} else {
// no user data
}
}
} else if (result.resultCode == Activity.RESULT_CANCELED) {
result.data?.extras?.let {
val error = it.get(ERROR) as BioException
Toast.makeText(this, "LOGON_RESULT_CANCELED", Toast.LENGTH_LONG).show()
}
}
}
Log.d("USER_UUID","${bioSharedPreferences.currentUser?.uuid}" )
In case of login error it is picked up from the resultLauncher when the resultCode is not RESULT_OK. The following errors may occur in case the client has not been configured correctly:
- "REDIRECT_URI_INVALID"
- "PLUGIN_ID_NOT_FOUND"
- "REDIRECT_URI_NOT_MATCH"
How can I scan a QR?
You will simply need to call:
ConfigFile.startBioScan(this,resultScanLauncher)
The registerForActivityResult collects the return result of the QR scan.
resultLauncherScan = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
when(result.resultCode) {
RESULT_OK -> {
activity.showCustomDialog(description = getString(R.string.bar_code_ok))
}
RESULT_CANCELED -> {
result.data?.extras?.let {
val bioException = it.get(ERROR) as BioException
DialogCustomManager(activity).showDialogError(bioException)
}
}
RESULT_OK_WITH_BIOMETRIC_CHANGES -> {
result.data?.extras?.let {
val bioException = it.get(ERROR) as BioException
DialogCustomManager(activity).showDialogError(bioException)
}
}
}
}
Once this action is done and the RESULT_OK code is returned, the process of accessing the user's information becomes part of the web where the QR is.
Remarks: We have a new parameter in the library to control the case that there are new biometric changes in the mobile terminal and the secureFlag has been set to FALSE in the library.
com.lib.bfy.utils.RESULT_OK_WITH_BIOMETRIC_CHANGES
Note: In order to be able to log in or scan a QR correctly, an enrolment and a correct verification of both the user's email and telephone has to be carried out and once this has been done, the user must have the biometrics of their device active.