IDSCustomerJourney
IDSCustomerJourney
Section titled “IDSCustomerJourney”Implementation
Section titled “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 requiredlet customerController = IDSCustomerJourneyController(config: nil)
// Specify CredentialscustomerController.credentials = IDSEnterpriseCredentials(username: username, password: password, urlPrefix: baseURL)
// Specify delegatecustomerController.delegate = self
// Optional: specify journeyDefinitionID if you would like to perform certain journeycustomerController.journeyDefinitionID = journeyDefinitionID
// PresentcustomerController.modalPresentationStyle = .fullScreenpresent(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
Section titled “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 = credentialscustomerController.delegate = self
// Only used if you would like to pass some additional data to the backend for requestcustomerController.prepareForEnterpriseRequest = { (request: IDSEnterpriseRequestModifier, requiredAction: IDSEnterpriseRequiredActionState) in let exampleEntry = IDSEnterpriseAdditionalDataEntry(name: "ExampleAdditionalData", value: "Action") request.addAdditionalData([exampleEntry])}Screen Injection
Section titled “Screen Injection”You will notice that IDSCustomerJourneyControllerwill 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 itselfself.finish()
// or if you want to completely cancel the journeyself.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 IDSCustomerJourneyUIControllerand 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
Section titled “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:
- Provide journey GUID when creating a customer journey controller
Swift
// specify journeyDefinitionID if you would like to perform certain journeycustomerController.journeyDefinitionID = journeyDefinitionID- Implement IDSCustomerJourneyControllerDelegatemethod and select appropriate journey from the provided list
Swift
func customerJourneyController(_ scanner: IDSCustomerJourneyController, selectJourneyDefinition journeyDefinitions: [IDSEnterpriseJourneyDefinition]?) -> IDSEnterpriseJourneyDefinition? { return journeyDefinitions?.last}- Use IDSEnterpriseServiceand pass the ID to customer journey as displayed in the example 1
Swift
IDSEnterpriseService.getJourneyDefinitions(with: credentials, completion: { (definitions: [IDSEnterpriseJourneyDefinition]?, error: Error?) in })