Skip to main content

Veritran Docs

How to Use XpressPlug in iOS Native Apps

After setting the correct parameters and initializing XpressPlug, all the available functions are ready to be used and interact with the SDK.

Warning

Only initialize XpressPlug once per session, preferentially during the app's launch or at the earliest stage possible. You will not be able to execute any entrypoint until XpressPlug is initialized.

You can interact with XpressPlug and call for entrypoints. These entrypoints are used to connect with Veritran's functionalities, such as processes or transactions.

Entrypoints can be visual, like invoking a screen that opens the device's camera to take a picture, or non-visual, such as validating a login. To interact with these entrypoints, enter the syntax below, where:

  • EntryPointName: String for the entrypoint's name.

  • Parameters: Input parameters to be used, following the format ([String,String]).

  • Delegate: Instance that implementes a delegate (XpressPlugDelegate).

  • viewController: ViewController that will invoke XpressPlug's view.

@objc public class XpressPlugSDK: NSObject { 
	@objc public static func run( 
       	 _ entryPointName: String, 
        	withParameters parameters: [String: String]?, 
        	andDelegate delegate: XpressPlugDelegate, 
        	andViewController viewController: UIViewController 
    ) 
} XpressPlugModule.callEntryPoint (entryPointName, inputParameters, outputKeys); 

Note

Entrypoints names and their parameters will be provided by the Veritran team

In the following example, the entrypoint is called I_DOCU_SDK, and its input parameters include a map with a string type username. The keys defined as output keys are "errorCode" and "age". As a result, the function returns a map with the <key, Value> format that contains values previously set in the outputKeys array. See the example below to learn how to call an entrypoint:

@IBAction func onClick(_: Any) { 
   print(“Calling XpressPlugModule EntryPoint”) 
    XpressPlugSDK.run( 
      " I_DOCU_SDK ", withParameters: [" userName ": "Veritran"], andDelegate: self, andViewController: self) 
  } 

Then, use the code below to implement XpressPlugDelegate:

//MARK: XpressPlug Delegate 
extension ViewController: XpressPlugDelegate { 
  func onError( 
    _ viewController: UIViewController, errorId: Int32, message: String, entryPoint: String? 
  ) { 
      print("XpressPlugModule EntryPoint Result errorId :\(errorId)") 
  } 

  func onUpdateConfigurationRequired(_ viewController: UIViewController, entryPoint: String?) {} 

  func onXpressPlugNeedsUpdate(_ viewController: UIViewController, entryPoint: String?) {}   

  func onClose(_ viewController: UIViewController, entryPoint: String?, result: OutboundParameters) 
  { 

      let age = result.get('age') 
      let statusCode = result.get('statusCode') 
      print("XpressPlugModule EntryPoint Result-- Age: \(age), StatusCode: \(statusCode)") 
  } 
} 

See the code and table below for an example of possible entrypoint results:

func onMessage(_ viewController: UIViewController, entryPoint: String?, command: String, result:
XPOutboundParameters) {
}
func onError(_ viewController: UIViewController, entryPoint: String?) {
}
func onUpdateConfigurationRequired(_ viewController: UIViewController, entryPoint: String?) {
}
func onUpdateSdkRequired(_ viewController: UIViewController, entryPoint: String?) {
}
func onClose(_ viewController: UIViewController, entryPoint: String?, result: XPOutboundParameters) {
}

onMessage

Returns the XpressPlug's status to the delegate.

onException

Executes when an error occurs.

onUpdateConfigurationRequired

Displays when the configuration needs to be updated.

onUpdateSdkRequired

Displays when the SDK needs to be updated.

onClose

Displays the result obtained after executing the entrypoints. It receives a dictionary with outbound parameters as the result parameter.