OnlineLivenessFragment is a simpler solution when implementing liveness as it handles the following internally:
- Uploading images for face matching
- Uploading the result from the liveness engine
- Retrieving the configuration from the response and setting in the liveness engine
OnlineLivenessFragment has the following dependencies :
- EnterpriseService – Your current instantiated enterprise service
- Credentials – Your currently instantiated credentials, make sure these are not empty
- OnResultLivenessListener – A listener that will provide a response of once liveness has been completed and submitted or network and scanner errors
- ResponseUpload – Your response from previous RequiredAction in your journey, This contains the liveness engine configuration which will be set. This is optional if nothing is provided then the default configuration will be used
- JourneyId – ID of the current journey, this is optional if it is not provided a random ID will be generated
Setting up OnlineLivenessFragment
Java
OnlineLivenessFragment livenessFragment = newOnlineLivenessFragment(enterpriseService,credentials,onlineLivenessListener,responseUpload,journeyId);
Kotlin
val livenessFragment = OnlineLivenessFragment(enterpriseService,credentials,onlineLivenessListener,responseUpload, //optionaljourneyId) //optional
OnlineLivenessFragment.OnResultListener
Java
privateOnlineLivenessFragment.OnResultLivenessListener onlineLivenessListener = newOnlineLivenessFragment.OnResultLivenessListener() {@OverridepublicvoidonResult(@NullableResponseUpload result) {//response after uploading aggregated result from liveness engine}@OverridepublicvoidonNetworkError(intcode, @NotNullString message) {//network error response codes can be found in [EnterpriseService]}@OverridepublicvoidonScannerError(@NotNullScannerError scannerError) {//scanner error response codes can be found in [ScannerError]}};
Kotlin
privateval onlineLivenessListener = object : OnlineLivenessFragment.OnResultLivenessListener {override fun onResult(result: ResponseUpload?) {//response after uploading aggregated result from liveness engine}override fun onNetworkError(code: Int, message: String) {//network error response codes can be found in [EnterpriseService]}override fun onScannerError(scannerError: ScannerError) {//scanner error response codes can be found in [ScannerError]}}