Interacción
Después de configurar los parámetros correctos e inicializar XpressPlug, puedes ejecutarlo. Para ello, invoca el método Sdk.start().
Aviso
[en] 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.
Crea una clase nueva que implementará el protocolo y modifícala como un parámetro del método de inicio. Luego, invócalo.
[en] 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:
[en] EntryPointName: String for the entrypoint's name.
[en] Parameters: Input parameters to be used, following the format ([String,String]).
[en] Delegate: Instance that implementes a delegate (XpressPlugDelegate).
[en] 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);
Nota
[en] Entrypoints names and their parameters will be provided by the Veritran team
[en] 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) }
[en] 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)") } }
[en] 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) { }
[en] onMessage | [en] Returns the XpressPlug's status to the delegate. |
[en] onException | [en] Executes when an error occurs. |
[en] onUpdateConfigurationRequired | [en] Displays when the configuration needs to be updated. |
[en] onUpdateSdkRequired | [en] Displays when the SDK needs to be updated. |
[en] onClose | [en] Displays the result obtained after executing the entrypoints. It receives a dictionary with outbound parameters as the result parameter. |