How to use XpressPlug in Android 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.
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:
class EntryPointCallerExample: EntryPoint.Callback { fun testEntryPointCall() { val entryPointName = "I_DOCU_SDK" val parameters = hashMapOf("userName" to "Veritran") val action = XpressPlug.buildEntryPoint( entryPointName, MainApplication.mainActivity ) parameters.forEach { action.addInput(it.key, it.value) } action.setCallback(this) action.execute() } }
Note
Entrypoints names and their parameters will be provided by the Veritran team
To see the entrypoints execution results, you need to implement the EntryPoint.Callback interface. See the code and table below for an example of how the interface is implemented after invoking the class above.
override fun onCompleted(results: Response?) { val outputKeys = listOf("errorCode", "age") var params = hashMapOf<String, String>() outputKeys.forEach { param -> params[param.name] = results?.getOutputValue(param.name) ?: "" } } override fun onException(code: String?, message: Exception?) { } override fun onUpdateRequired(message: String?) { } override fun onClose(message: String?, context: Activity?) { }
onCompleted | This is where the output parameters appear. |
onException | Executed when an exception occurs. |
onUpdateRequired | Displays when the SDK or configuration need to be updated. |
onClose | Displays when the functionality is closed |
Result values can be accessed through the Response object, on the onCompleted method.