Skip to content

React Native APIs

The following React Native APIs are utilized for the communication between the React Native app framework and the VoltMX Iris Framework. These React Native APIs are available from V9 SP2 onwards.

reactNative.invokeVoltMXCallback


This API invokes the VoltMX Iris callback, which is registered in the VoltMX Iris app by using the voltmx.reactNative.setCallback API.

Syntax


reactNative.invokeVoltMXCallback(id, args)

Note: You must prefix NativeModules while calling this API, if NativeModules.reactNative is not exported from the React Native module and if the same is not imported in the module file where this API is used.

Input Parameters

Parameter Description
id Request identifier of the ReactNative app. This parameter is used to bind the request with the response. > Note: If a request has to listen for a response, you must register the listener/callback for the request by using the reactNative.setCallback API and leveraging the same id parameter as of the reactNative.invokeVoltMXCallback API. > Note: The value of the id parameter must follow this format: ReactNativeAppName + unique string.
args Object with key–value pair elements with key as String and value as Object, such as Number, Boolean, String, Array, and Object. This parameter is used to pass data from the React Native app to the VoltMX Iris app context.

reactNativeCallback registers a React Native callback function. This callback will be invoked by using the voltmx.reactNative.sendResult API from the VoltMX Iris app context.

Example


args = {
    operation:"fetchAccounts"
};
NativeModules.reactNative.invokeVoltMXCallback(<id>, args);  

//You can omit the NativeModules prefix if NativeModules.reactNative is exported from the React Native module   
//and the same is imported in the module file where this API is used.

Return Value

None

Platform Availability

  • iOS
  • Android

reactNative.setCallback


This API is used to register a callback/listener to receive the result/response from the VoltMX Iris app context. The registered callback will be invoked while using the voltmx.reactNative.sendResult API from the VoltMX Iris app context.

Syntax


reactNative.setCallback(id, Callback)

Input Parameters

Parameter Description
id Request identifier for the React Native app. Since there can be multiple React Native apps integrated in to a VoltMX Iris app, the id parameter is used to distinguish between the different React Native apps as well as to differentiate different invocations from the same app. > Note: The value of the id parameter must follow this format: ReactNativeAppName + unique string.
Callback JavaScript function. Callbacks are internally maintained as a dictionary of this API's id and Callback parameters. The callback will be removed from the dictionary once the result is sent (by using the voltmx.reactNative.sendResult API) to avoid an exception of the React Native framework. This exception occurs when the voltmx.reactNative.sendResult API is called more than once per request.

Example


function reactNativeCallback(resultData){
  ..........
};

NativeModules.reactNative.setCallback(<id>, reactNativeCallback);  

//You can omit the NativeModules prefix if NativeModules.reactNative is exported from the React Native module   
//and the same is imported in the module file where this API is used.

Return Value

None

Platform Availability

  • iOS
  • Android