All Products
Search
Document Center

SuperApp:Specifications and limits

Last Updated:Aug 29, 2024

This topic describes the specifications and limits based on which you use JavaScript APIs of WindVane miniapps.

UA specifications

WindVane appends a WindVane tag, the version of WindVane SDK, the additional User-Agent (UA) of the client, and the resolution of the current screen to the value of the default UA to help you determine the environment.

A complete UA includes the following elements: Default UA (including an app name or an app version), Version of WindVane or WindVane SDK, Additional UA of the client, Resolution (WxH). Each item is separated by a space.

Sample Android UA:

Mozilla/5.0 (Linux; Android 10; TAS-AN00 Build/HUAWEITAS-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.93 Mobile Safari/537.36 TTID/aaa WindVane/8.5.0

Sample iOS UA:

Mozilla\/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Mobile\/19F70 AliApp(EMASDemo\/2.0.0) WindVane\/8.6.1 TBIOS 1170x2532
  • WindVane iOS allows you to use the setAppUA method to configure the additional UA of the client. Make sure that the lowercase letter x is used when including the resolution in the UA.

  • WindVane Android does not provide a method to configure the additional UA of the client. Make sure that the uppercase letter X is used when including the resolution in the UA.

Important

We recommend that you do not use the additional UA of the client to determine the OS and version of the client.

JavaScript API specifications

You can use window.WindVane.call(className, methodName, params, successCallback, failureCallback, timeout) to call the features of the client.

Note

JavaScript APIs cannot be called inside iframes.

Input parameters

Type

Parameter

Description

string

className

The name of the client class that you want to call.

string

methodName

The name of the client method that you want to call.

object

params

The parameters that you want to pass to the client.

function

successCallback

The callback that is performed after JSBridge is called.

function

failureCallback

The callback that is performed after JSBridge fails to be called.

number

timeout

Optional. The call of JSBridge times out. If the timeout occurs, the {ret:['HY_TIMEOUT']} parameter is automatically included in the callback function.

Both successCallback and failureCallback are called by the native apps. If you want to use try...catch to catch exceptions, write try...catch in the callback function.

In this topic, the client class name and method that need to be called are specified in the className.methodName format.

Callback parameter: If the client API is called, a success callback is performed. If the client API fails to be called, a failure callback is performed. The parameters of the callback function vary based on the API that is called.

ret in the callback parameter: Callback parameters may include the ret property. This property indicates the status of the callback. The following table describes the valid values of the ret property.

Value

Description

'HY_SUCCESS'

Indicates that the API call is successful. This value is used only in a success callback.

'HY_CLOSED'

Indicates that the JSBridge feature is forcibly disabled. In most cases, this issue occurs because the URL of the page is not specified in the list of trusted domains or the JSBridge feature is not enabled for native apps. If this issue occurs, check the URL or contact HTML5 container-native developers to troubleshoot the issue.

'HY_NO_HANDLER'

Indicates that the current client does not provide this API. Check whether the called JSBridge is correct and contact the provider of the native apps for JSBridge to troubleshoot the issue.

'HY_PARAM_ERR'

Indicates that the input parameter is invalid. Make sure that the input parameter is valid.

'HY_NO_PERMISSION'

Indicates that the current page does not have permissions to call this API.

'HY_FAILED'

Indicates that the API call fails. Contact the provider of the native apps for JSBridge to troubleshoot the issue.

'HY_EXCEPTION'

Indicates that an error occurs when the API is called. Contact the provider of the native apps for JSBridge to troubleshoot the issue.

'HY_USER_DENIED'

Indicates that the API is not granted the permissions to perform the operation. For example, a client wants to call this API to access the album, but the client is not allowed to access the album.

'HY_USER_CANCELLED'

Indicates that the user canceled the current API request.

'HY_RET_PHOTO_CANCLE'

Indicates that the user cancels the request for taking photos by using the API provided by WVCamera.

'HY_TIMEOUT'

Indicates that the call of JSBridge times out.

'HY_RESULT_PARSE_ERROR'

Indicates that the format of the data passed by native apps to HTML5 is invalid.

'HY_NOT_IN_WINDVANE'

Indicates that the current environment is not WindVane such as a browser, or that UserAgent of WindVane provided by the client is invalid. Alternatively, JavaScript of the page incorrectly modified an environment variable in the windvane.js file. For example, WindVane.isAvailable is set to false.

'HY_NOT_SUPPORT_DEVICE'

Indicates that JSBridge is called on a device or in an environment that is not supported, such as a browser. Alternatively, a JavaScript action on the page incorrectly modified an environment variable in the windvane.js file. For example, WindVane.isAvailable is set to false.

'HY_NO_HANDLER_ON_WP'

Indicates that JSBridge is called on a Windows device or in an environment that is not supported, such as a browser.

'WV_ERR::PARAM_PARSE_ERROR'

Indicates that the format of the data passed by native apps to HTML5 is invalid.

The value of the ret property varies based on the JavaScript API that is called. The value of the ret property can be an empty string, a string, or an array. ret[0] includes the execution state of the client API. Not all JavaScript APIs can call the callback function. The invocation of the callback function by using JavaScript APIs is related to the implementation of the client. The JavaScript API documentation describes the usage scenarios in which a success callback or a failure callback occurs.