Calling Native Functions
To call native Swift functions from JavaScript, include the enClose.js
library in your HTML file. Then use the enClose
function to create the bridge between JavaScript and Swift.
Function Syntax
javascript
enClose(nativeCall, data, successCallback, errorCallback);
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
nativeCall | String | Yes | Name of the native Swift method to call |
data | Object | No | Object containing arguments to pass to the Swift method |
successCallback | String | No | Name of the JavaScript function to execute upon successful completion |
errorCallback | String | No | Name of the JavaScript function to execute if an error occurs |
Example Usage
javascript
enClose(
nativeCall: 'processUserData',
data: {
foo: 123,
bar: 'hello'
},
successCallback: 'handleSuccess',
errorCallback: 'handleError'
);