Quick Setup
After following the install instructions and getting set up in IEOS, you are ready to use MJCS.
App setup
Prior to launching MJCS, you should call the following method:
MJCS.init(applicationContext)
You can either put this in your Application's onCreate function or your main activity's, but this should occur before any calls to MJCS.
Creating the MJCS Credentials
First you will need to create a credentials object using one of the following methods:
val credentials: Credentials = Credentials(username, password)
or for token init:
val credentials: Credentials = Credentials().apply { setToken(token) }
Creating the MJCS Config
There are some additional configuration methods that can be called on the Journey Config Builder, but for this example we are just showing the basic code to get MJCS running. For additional configuration options, see mjcs customization.
val baseUrl: String = "https://$your_enviroment.idscan.cloud"
val journeyDefinitionGUID: String = "$your_journey_id"
val config: CustomerJourneyConfig = CustomerJourneyConfig.Builder(
baseUrl,
credentials
).setJourneyDefinitionId(journeyDefinitionGUID).build()
Register Event Listener
Most implementations will want to be able to respond to events that occur during the MJCS journey. In order to do so, you should register your activity as a CustomerJourneyEventListener. First create a listener, either as an object or by having your activity implement the following interface:
interface CustomerJourneyEventListener {
/**
* Returns onJourney completed callback with Journey Results.
*/
fun onJourneyCompleted(responseJourney: ResponseJourney)
/**
* Journey failed callback, [CustomerJourneyError] has error codes witch can happen.
*/
fun onJourneyFailed(customerJourneyError: CustomerJourneyError)
/**
* Journey was canceled by user callback. Most likely customer clicked onBack or cancel button.
*/
fun onJourneyCanceled(customerJourneyError: CustomerJourneyError)
/**
* Provides version information
*/
fun onServerInfo(info: ResponseVersionInfo)
}
For additional details about error codes see references.
Then in your activity's onStart method register the listener:
MjcsEventService.registerService(activity) { mjcsEventService: MjcsEventService? ->
mjcsEventService?.customerJourneyEventListener = yourListener
}
Launching MJCS
Finally to launch MJCS, all you need to do is to supply the config object created above to the following method:
CustomerJourneyActivity.startActivity(this@RootActivity, config)