Implementing OnlineLivenessFragment – GBG IDscan Documentation

Implementing OnlineLivenessFragment

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 = new OnlineLivenessFragment(enterpriseService,
                              credentials,
                              onlineLivenessListener,
                              responseUpload,
                              journeyId); 

Kotlin

val livenessFragment = OnlineLivenessFragment(
              enterpriseService,
              credentials,
              onlineLivenessListener,
              responseUpload, //optional
              journeyId) //optional 

OnlineLivenessFragment.OnResultListener

Java

private OnlineLivenessFragment.OnResultLivenessListener onlineLivenessListener = new OnlineLivenessFragment.OnResultLivenessListener() {
    @Override
    public void onResult(@Nullable ResponseUpload result) {
        //response after uploading aggregated result from liveness engine
    }
 
    @Override
    public void onNetworkError(int code, @NotNull String message) {
        //network error response codes can be found in [EnterpriseService]
    }
 
    @Override
    public void onScannerError(@NotNull ScannerError scannerError) {
        //scanner error response codes can be found in [ScannerError]
    }
}; 

Kotlin

private val 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]
    }
} 

Was this page helpful?