It’s as easy as implementing a listener and calling another activity:
Journey will be done as defined by IEOS Customer Journey configuration.
- Implement or create an instance of CustomerJourneyEventReceiver implementation.
private CustomerJourneyEventReceiver implementation = new CustomerJourneyEventReceiver() {
@Override
public void onJourneyCompleted(Context context, ResponseJourney responseJourney) {
// Results from Customer Journey
}
@Override
public void onJourneyFailed(Context context, CustomerJourneyError errorCode) {
// Failed check error object for more information. At the end see possible errorCodes.
}
@Override
public void onJourneyCanceled(Context context, CustomerJourneyError error) {
// If journey was cancelled, onBack() click event.
}
};
Kotlin
// Callback interface of Customer journey
private val response: CustomerJourneyEventReceiver = object : CustomerJourneyEventReceiver() {
/* Called back if customer clicked back or exits Customer Journey. */
override fun onJourneyCanceled(context: Context, customerJourneyError: CustomerJourneyError) {
}
/* Callback if journey was successfully completed. */
override fun onJourneyCompleted(context: Context, responseJourney: ResponseJourney) {
}
/* Callback for failure from witch we dit not succeed to restore our self. */
override fun onJourneyFailed(context: Context, customerJourneyError: CustomerJourneyError) {
}
}
- Register your implementation using
Note: Kotlin register before and unregister after response, as register would create a new instance and not override the old.
// Register before call CustomerJourneyService.registerEventReceiver(context, implementation);
// Unregister after call CustomerJourneyService.unregisterEventReceiver(context, implementation);
- Create an intent with:
- EXTRA_BASE_LINK: Add server base URL if POC server provided by GBG IDscan its most likely https://company.idscan.cloud
- CREDENTIALS: Add Scanning Area credentials
- Intent to CustomerJourneyActivity and start it.
// Create intent to start scanner activity
Intent customerJourney = new Intent(this, CustomerJourneyActivity.class);
customerJourney.putExtra(CustomerJourneyActivity.EXTRA_BASE_LINK, baseUrl);
customerJourney.putExtra(CustomerJourneyActivity.EXTRA_CREDENTIALS, new Credentials(username, password));
startActivity(customerJourney);
Note: Don’t forget to add a check for camera permissions.
Possible onJourneyFailed(CustomerJourneyError) codes:
Code | Description |
EnterpriseService EXCEPTION_ERROR 500 | Returns when Web service experienced unrecoverable situation and returns localised exception message. |
408 | Internal server error, more information on server side. Server time out |
401 | Unauthorised, possibly bad credentials. |
400 | Bad Request |
… | Other error HTTP status codes possible https://en.wikipedia.org/wiki/List_of_HTTP_status_codes |
CustomerJourneyError | Errors from customer journey itself |
NONE | No error |
GENERAL | General error check message |
NO_SERVER_RESPONSE | Journey Failed server din’t respond |
UNKNOWN_REQUIRED_ACTION | Journey Failed because of unknown action |
CAMERA | Journey Failed because of camera failure |
WEB_INITIALIZING | Creating webservice instance failed |
WEB_INITIALIZING_BAD_URL | Creating Retrofit instance failed with IllegalArgumentException |
EXECUTION | Execution error, most likely exceptions from witch we are not recovering, will send exception localised message. |
For more information check JavaDocs on possible call exceptions.