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.
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.
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.
import androidx.activity.ComponentActivityimport ae.gov.icp.uaekyc.UaeKycSdkimport ae.gov.icp.uaekyc.JourneyCallbackimport ae.gov.icp.uaekyc.JourneyResultimport ae.gov.icp.uaekyc.StartResultimport ae.gov.icp.uaekyc.models.config.Languageimport ae.gov.icp.uaekyc.models.config.Logoimport ae.gov.icp.uaekyc.models.config.JourneyConfigimport ae.gov.icp.uaekyc.models.config.Themeimport ae.gov.icp.uaekyc.Rclass 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 }}
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;public class MainActivity extends ComponentActivity { private UaeKycSdk sdk; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create SDK instance sdk = UaeKycSdk.create(getApplicationContext()); // Register callback sdk.registerCallback(this, this::handleJourneyResult); } private Logo getBrandingLogo() { // You can also load a Bitmap and use Logo.Bitmap here return new Logo.Drawable(R.drawable.logo_resource); } // Call this function in a background thread // when you want to start the journey private void startJourney() { final String domain = "your.domain.ae"; final JourneyConfig journeyConfig = new JourneyConfig.Builder() .setJourneyToken("<insert-journey-token>") .setPrivacyPolicyLink("<insert-link>") .setLogo(getBrandingLogo()) .setAccentColor(0xFFCFB16C) .setTheme(Theme.LIGHT) .setLanguage(Language.English) .build(); final StartResult result = sdk.startJourney(domain, journeyConfig); if (result instanceof StartResult.Success) { // Journey started successfully } else if (result instanceof StartResult.PreConditionFailure) { final String reason = ((StartResult.PreConditionFailure) result).getReason(); } else if (result instanceof StartResult.SessionExpired) { // The provided token is no longer valid } else if (result instanceof StartResult.Blocked) { // Journey is blocked due to multiple failed attempts } else if (result instanceof StartResult.Error) { Log.e("MainActivity", "Error occurred: " + ((StartResult.Error) result).getErrorCode()); } } private void handleJourneyResult(final JourneyResult result) { // Handle journey result... } @Override protected void onDestroy() { super.onDestroy(); if (sdk != null) { sdk.unregisterCallback(); sdk.close(); sdk = null; } }}
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().
View deprecated SDK singleton API
MainActivity.kt
MainActivity.java
import ae.gov.icp.uaekyc.SDKimport ae.gov.icp.uaekyc.models.config.Languageimport ae.gov.icp.uaekyc.models.config.Logoimport ae.gov.icp.uaekyc.models.config.JourneyConfigimport ae.gov.icp.uaekyc.models.config.Themeimport ae.gov.icp.uaekyc.Rimport ae.gov.icp.uaekyc.StartResult// DEPRECATED: Use UaeKycSdk instance methods insteadclass 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 -> { } } }}
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 insteadpublic class MainActivity extends ComponentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Register the callback here (deprecated)... } private Logo getBrandingLogo() { return new Logo.Drawable(R.drawable.logo_resource); } // Call this function in a background thread (deprecated) private void startJourney() { final JourneyConfig journeyConfig = new JourneyConfig.Builder() .setJourneyToken("<insert-journey-token>") .setPrivacyPolicyLink("<insert-link>") .setLogo(getBrandingLogo()) .setAccentColor(0xFFCFB16C) .setTheme(Theme.LIGHT) .setLanguage(Language.English) .build(); // Deprecated: domain was set in SDK.INSTANCE.initialize() final StartResult result = SDK.INSTANCE.startJourney(journeyConfig, getApplicationContext()); if (result instanceof StartResult.Success) { // Journey started successfully } else if (result instanceof StartResult.PreConditionFailure) { final String reason = ((StartResult.PreConditionFailure) result).getReason(); } else if (result instanceof StartResult.SessionExpired) { // Token expired } else if (result instanceof StartResult.Blocked) { // Blocked } else if (result instanceof StartResult.Error) { Log.e("MainActivity", "Error occurred: " + ((StartResult.Error) result).getErrorCode()); } }}