Skip to main content
After starting the journey, you will need to handle the result of the process. The result is passed to the callback you registered earlier and can take various forms depending on the success or failure of the journey. The result will be an instance of the JourneyResult interface, which can represent different outcomes as given below.

JourneyResult

JourneyResult is a sealed interface representing different possible results of a journey.

Success

Represents a successful journey.

DocumentVerificationFailed

Indicates that the document verification process was unsuccessful, usually because of incorrect or poor-quality documents.

ICPVerificationFailed

Indicates that the ICP could not successfully verify the individual’s data presented.

Cancelled

Indicates that the journey was cancelled by the user.

SessionExpired

Indicates that the session timed out before the journey was completed by the user.

Error

Represents a failure due to internal errors, identified by an integer error code accessible via the errorCode property in Kotlin or getErrorCode() method in Java. For a complete list of error codes, see Android SDK Error Codes.

Sample code for handling JourneyResult

import ae.gov.icp.uaekyc.journey.ICPDetails
import ae.gov.icp.uaekyc.JourneyResult
import ae.gov.icp.uaekyc.SDK

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        SDK.registerCallback(this, ::handleJourneyResult)
    }

    private fun handleJourneyResult(result: JourneyResult) {
        when (result) {
            JourneyResult.Success -> {
                // Handle success
            }
            JourneyResult.DocumentVerificationFailed -> {
                // Handle document verification failure
            }
            JourneyResult.ICPVerificationFailed -> {
                // Handle ICP verification failure
            }
            JourneyResult.Cancelled -> {
                // Handle cancellation
            }
            JourneyResult.SessionExpired -> {
                // Handle session expiry
            }
            is JourneyResult.Error -> {
                Log.e("MainActivity", "Error occurred: ${result.errorCode}")
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        SDK.unregisterCallback()
    }
}