Skip to content

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

ParameterTypeRequiredDescription
nativeCallStringYesName of the native Swift method to call
dataObjectNoObject containing arguments to pass to the Swift method
successCallbackStringNoName of the JavaScript function to execute upon successful completion
errorCallbackStringNoName 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'
);