IDSCustomerJourney – GBG IDscan Documentation

IDSCustomerJourney

IDSCustomerJourney

Implementation

This class serves the fastest and easiest implementation of MJCS to perform on-boarding journey. The class abstracts all the business logic required to capture data and provides the aggregated result in the end. All you need are a few lines of code:

Swift

// Init a controller with a config if required
let customerController = IDSCustomerJourneyController(config: nil)
 
// Specify Credentials
customerController.credentials = IDSEnterpriseCredentials(username: username, password: password, urlPrefix: baseURL)
 
// Specify delegate
customerController.delegate = self
 
// Optional: specify journeyDefinitionID if you would like to perform certain journey
customerController.journeyDefinitionID = journeyDefinitionID
 
// Present
customerController.modalPresentationStyle = .fullScreen
present(customerController, animated: true, completion: nil)

That’s it! Once presented, the controller will do all required steps. Depending on the outcome, you should listen to the delegate methods that are documented under IDSCustomerJourneyControllerDelegate interface.

Additional Data

IDSCustomerJourneyController got the following property, which is a closure, that allows you to add some additional data to backend requests.

Property

/**
Use this closure to modify the request to the backend, which will be sent for the provided action
*/
@property (nonatomic, copy) void (^ _Nonnull prepareForEnterpriseRequest)(IDSEnterpriseRequestModifier *_Nonnull request, IDSEnterpriseRequiredActionState *_Nonnull requiredAction);

Above property can be used to add additional data to “IDSCustomerJourneyController” instance. An array of “IDSEnterpriseAdditionalDataEntry” instances need to be set to “IDSEnterpriseRequestModifier” parameter through “addAdditionalData” function call. Sample code is added below for demonstration.

Use Of Additional Data

let credentials: IDSEnterpriseCredentials = // Create credentials...
let config: IDSCustomerJourneyConfig = // Create config...
let customerController = IDSCustomerJourneyController(config: config)
customerController.credentials = credentials
customerController.delegate = self
 
// Only used if you would like to pass some additional data to the backend for request
customerController.prepareForEnterpriseRequest = {
    (request: IDSEnterpriseRequestModifier, requiredAction: IDSEnterpriseRequiredActionState) in
    let exampleEntry = IDSEnterpriseAdditionalDataEntry(name: "ExampleAdditionalData", value: "Action")
    request.addAdditionalData([exampleEntry])
}

Screen Injection

You will notice that IDSCustomerJourneyController will do all the flow on it’s own. There might be cases, when the app would need to display some instruction between the steps, which could be easily implemented using the following steps:

Create a UIViewController that you will want to be displayed. It must be a subclass of our own ViewController: IDSCustomerJourneyUIController

Inside your controller you can implement any business logic you may require. MJCS only requires you to call 2 methods within the controller:

Swift

// When user has finished with all instructions and you want to proceed to the step itself
self.finish()
 
// or if you want to completely cancel the journey
self.cancel()

Implement additional IDSCustomerJourneyControllerDelegate method and return your view controller:

Swift

func customerJourneyController(_ scanner: IDSCustomerJourneyController, intermediateVCForStep nextStep: IDSEnterpriseRequiredActionState, enterpriseResponse: IDSEnterpriseResponse?) -> (IDSCustomerJourneyUIController & IDSCustomerJourneyUIUploadingProtocol)?

You may also want to display a screen when we upload data to the backend. In that case, you should return ViewController that is subclassed from IDSCustomerJourneyUIController and adheres to protocol IDSCustomerJourneyUIUploadingProtocol. Afterwards, you just need to implement additional delegate method and return the ViewController

Swift

func customerJourneyController(_ scanner: IDSCustomerJourneyController, intermediateUIForUploadingState currentStep: IDSEnterpriseRequiredAction) -> (IDSCustomerJourneyUIController & IDSCustomerJourneyUIUploadingProtocol)?

Journey Definitions

IEOS backend has a possibility to have different journey configurations for mobile channel depending on your needs.

There are 3 ways how we can access specific journey:

1. Provide journey GUID when creating a customer journey controller

Swift

// specify journeyDefinitionID if you would like to perform certain journey
customerController.journeyDefinitionID = journeyDefinitionID

2. Implement IDSCustomerJourneyControllerDelegate method and select appropriate journey from the provided list

Swift

func customerJourneyController(_ scanner: IDSCustomerJourneyController, selectJourneyDefinition journeyDefinitions: [IDSEnterpriseJourneyDefinition]?) -> IDSEnterpriseJourneyDefinition? {
    return journeyDefinitions?.last
}

3. Use IDSEnterpriseService and pass the ID to customer journey as displayed in the example 1

Swift

IDSEnterpriseService.getJourneyDefinitions(with: credentials, completion: { (definitions: [IDSEnterpriseJourneyDefinition]?, error: Error?) in })

Was this page helpful?