Skip to main content
To start the journey, you need to create a JourneyConfig object. This object contains necessary details for proceeding with a journey such as the journeyToken. You can use the JourneyConfig.Builder to construct the configuration with journey token. See Create Journey API on how to get the journey token. Once the configuration is built, you can start the journey by calling the sdk.startJourney() method inside your Activity. This method is blocking and should not be called on the UI thread.
Deprecated API Notice — The static SDK.startJourney(config, context) method is deprecated. Use the instance method sdk.startJourney(domain, config) instead as shown below.

startJourney Parameters

Following are the parameters required for the startJourney function:
ParameterData TypeRequiredDescription
domainStringYesThe FQDN or FQDN + path prefix for HTTP requests.
configJourneyConfigYesThe journey config that will setup the journey.
JourneyConfig.Builder has functions for setting up the following parameters:
ParameterData TypeRequiredDescription
journeyTokenStringYesThe journey token as mentioned above.
privacyPolicyLinkStringNoPrivacy policy link shown to the user regarding consent. If omitted, not displayed in the consent screen.
logoLogoYesThe branding logo displayed at the top of the application bar. Can be a drawable resource or a Bitmap.
accentColorIntYesThe accent color for the UI as an ARGB color integer.
themeEnumNoUI theme: Theme.SYSTEM, Theme.LIGHT, Theme.DARK. Defaults to system theme.
languageEnumNoDefault language: Language.English, Language.Arabic. Defaults to system locale.

StartResult

StartResult is a sealed interface representing different possible outcomes while starting a journey with startJourney method invocation.

Success

Indicates that the journey started successfully and further outcomes will be dependent on the user actions.

Blocked

Indicates that the journey is blocked due to multiple failed verification attempts. See Journey Blocking Mechanism.

PreConditionFailure

Indicates that some precondition that is to be met before calling startJourney. The reason can be obtained via the reason property in Kotlin or getReason() method in Java.

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.

SessionExpired

Indicates that the session for the given journey token is already expired.
import androidx.activity.ComponentActivity
import ae.gov.icp.uaekyc.UaeKycSdk
import ae.gov.icp.uaekyc.JourneyCallback
import ae.gov.icp.uaekyc.JourneyResult
import ae.gov.icp.uaekyc.StartResult
import ae.gov.icp.uaekyc.models.config.Language
import ae.gov.icp.uaekyc.models.config.Logo
import ae.gov.icp.uaekyc.models.config.JourneyConfig
import ae.gov.icp.uaekyc.models.config.Theme
import ae.gov.icp.uaekyc.R

class MainActivity : ComponentActivity() {
    private var sdk: UaeKycSdk? = null

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

        // Create SDK instance
        sdk = UaeKycSdk.create(applicationContext)

        // Register callback
        sdk?.registerCallback(this, object : JourneyCallback {
            override fun onResult(result: JourneyResult) {
                handleJourneyResult(result)
            }
        })
    }

    private fun brandingLogo(): Logo {
        // You can also load a Bitmap and use Logo.Bitmap here
        return Logo.Drawable(R.drawable.logo_resource)
    }

    // Call this function in a background thread
    // when you want to start the journey
    private fun startJourney() {
        val domain = "your.domain.ae"

        val journeyConfig = JourneyConfig.Builder()
            .setJourneyToken("<insert-journey-token>")
            .setPrivacyPolicyLink("<insert-link>")
            .setLogo(brandingLogo())
            .setAccentColor(0xFFCFB16C)
            .setTheme(Theme.LIGHT)
            .setLanguage(Language.English)
            .build()

        // Handle start result
        when (val result = sdk?.startJourney(domain, journeyConfig)) {
            is StartResult.Error -> {
                val errorCode = result.errorCode
                // Start journey failed with an error code.
                Log.e("MainActivity", "Error occurred: $errorCode")
            }
            is StartResult.PreConditionFailure -> {
                val reason = result.reason
                // Some precondition was not met
            }
            StartResult.SessionExpired -> {
                // The provided token is no longer valid
            }
            StartResult.Blocked -> {
                // Journey is blocked due to multiple failed attempts
            }
            StartResult.Success -> {
                // Journey started successfully
            }
            null -> {
                // SDK not initialized
            }
        }
    }

    private fun handleJourneyResult(result: JourneyResult) {
        // Handle journey result...
    }

    override fun onDestroy() {
        super.onDestroy()
        sdk?.unregisterCallback()
        sdk?.close()
        sdk = null
    }
}

Deprecated API

Deprecated — The following static SDK.startJourney(config, context) method is deprecated. Use sdk.startJourney(domain, config) instead.Note: In the deprecated API, the domain was passed to SDK.initialize(). In the new API, domain is passed directly to startJourney().
import ae.gov.icp.uaekyc.SDK
import ae.gov.icp.uaekyc.models.config.Language
import ae.gov.icp.uaekyc.models.config.Logo
import ae.gov.icp.uaekyc.models.config.JourneyConfig
import ae.gov.icp.uaekyc.models.config.Theme
import ae.gov.icp.uaekyc.R
import ae.gov.icp.uaekyc.StartResult

// DEPRECATED: Use UaeKycSdk instance methods instead
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // Register the callback here (deprecated)...
    }

    private fun brandingLogo(): Logo {
        return Logo.Drawable(R.drawable.logo_resource)
    }

    // Call this function in a background thread (deprecated)
    private fun startJourney() {
        val journeyConfig = JourneyConfig.Builder()
            .setJourneyToken("<insert-journey-token>")
            .setPrivacyPolicyLink("<insert-link>")
            .setLogo(brandingLogo())
            .setAccentColor(0xFFCFB16C)
            .setTheme(Theme.LIGHT)
            .setLanguage(Language.English)
            .build()

        // Deprecated: domain was set in SDK.initialize()
        when (val result = SDK.startJourney(journeyConfig, this)) {
            is StartResult.Error -> {
                val errorCode = result.errorCode
                Log.e("MainActivity", "Error occurred: $errorCode")
            }
            is StartResult.PreConditionFailure -> {
                val reason = result.reason
            }
            StartResult.SessionExpired -> { }
            StartResult.Blocked -> { }
            StartResult.Success -> { }
        }
    }
}