All Products
Search
Document Center

SuperApp:WVBase

Last Updated:Sep 02, 2025

This topic describes the JavaScript APIs of WVBase. You can refer to this topic when you develop miniapps. You can use the JavaScript APIs of WVBase to copy and paste text, configure UI background color, and check whether a specified app is installed and whether APIs are supported by the current WindVane SDK version.

WVBase.copyToClipboard

Copies the specified text to the clipboard.

Input parameters

  • [string]text: the text that you want to copy to the clipboard.

Callback parameters

No callback parameters exist. If the text is copied to the clipboard, the success callback is invoked. Otherwise, the failure callback is invoked.

var params = {
        text: "text to copy"
};
window.WindVane.call('WVBase', 'copyToClipboard', params, function(e) {
        alert('success' + JSON.stringify(e));
}, function(e) {
        alert('failure' + JSON.stringify(e));
});

WVBase.isInstall

Checks whether the specified app is installed.

Note

In iOS 9 or later, you can check whether an app is installed based only on the scheme that is configured in LSApplicationQueriesSchemes of info.plist.

Input parameters

  • [string]ios: the app label that is used in iOS. In iOS, the schema of an app is used as the label. Example: 'taobao://'.

  • [string]android: the app label that is used in Android. In Android, the package name of an app is used as the label. Example: 'com.taobao.taobao'.

Callback parameters

No callback parameters exist. If the specified app is installed, the success callback is invoked. Otherwise, the failure callback is invoked.

var params = {
        // The app label that is used in iOS.
        ios: 'taobao://',
        // The app label that is used in Android.
        android: 'com.taobao.taobao'
};
window.WindVane.call('WVBase', 'isInstall', params, function(e) {
        alert('success');
}, function(e) {
        alert('failure');
});

WVBase.isAppsInstalled

Checks whether the specified apps are installed.

Note

In iOS 9 or later, you can check whether an app is installed based only on the scheme that is configured in LSApplicationQueriesSchemes of info.plist.

Input parameters

  • [object]appName: the apps whose installation status you want to check. The value of this parameter is an object and contains the following properties:

    • [string]ios: the app label that is used in iOS. In iOS, the schema of an app is used as the label. Example: 'taobao://'.

    • [string]android: the app label that is used in Android. In Android, the package name of an app is used as the label. Example: 'com.taobao.taobao'.

Callback parameters

Callback parameters are passed in the callback method. If the specified apps are installed, the success callback is invoked. Otherwise, the failure callback is invoked.

  • [boolean]appName: indicates whether the specified apps are installed.

var params = {
        taobao: {
                ios: 'taobao://',
                android: 'com.taobao.taobao'
        },
        tmall: {
                ios: 'tmall://',
                android: 'com.tmall.tmall'
        }
};
window.WindVane.call('WVBase', 'isAppsInstalled', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVBase.notify

Note

This API is available only for WindVane iOS.

Triggers the specified event in document.

Input parameters

  • [string]event: the name of the event that the WVBase.notify API is called to trigger.

  • [object]param: the parameters of the event that the WVBase.notify API is called to trigger.

Callback parameters

No callback parameters exist, and no success or failure callback is invoked.

Event listening

The event is specified by the event parameter and the parameters of the event are specified by the param parameter.

document.addEventListener('MyNotifyName', function(e) {
        alert(JSON.stringify(e.param));
}, false);

var params = {
        // The name of the event that the WVBase.notify API is called to trigger.
        event: 'MyNotifyName',
        // The parameters of the event that the WVBase.notify API is called to trigger.
        param: { MyEventParam: 'paramValue' }
};
window.WindVane.call('WVBase', 'notify', params);

WVBase.openBrowser

Note

This API is available only for WindVane iOS.

Opens a new Safari page to access a specified URL.

Input parameters

  • [string]url: the URL that is displayed in Safari.

Important

Use JSBridge only when you need to ensure that the URL is opened in Safari. In other cases, use the <a> hyperlink, configure location.href, or configure iframe to access the specified URL.

Callback parameters

No callback parameters exist. If a Safari page is successfully opened by using the specified URL, the success callback is invoked. Otherwise, the failure callback is invoked.

var params = {
        // The URL that is displayed in Safari.
        url: 'http://www.baidu.com'
};
window.WindVane.call('WVBase', 'openBrowser', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVBase.setBackgroundColor

Note

This API is available only for WindVane iOS.

Configures the background color of WebView.

Input parameters

  • [string]color: the hexadecimal color codes of the background color of WebView. The 0X or # prefix is supported.

  • [number]alpha: optional. The opacity of the WebView background color. Valid values: [0, 1].

Callback parameters

No callback parameters exist. If the opacity of the WebView background color is successfully configured, the success callback is invoked. Otherwise, the failure callback is invoked.

var params = {
        color: 'FF0000',
        alpha: 0.3
};
window.WindVane.call('WVBase', 'setBackgroundColor', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVBase.canIUse

Note

This API is available only for WindVane Android 1.0.3.4 or later.

Checks whether the API is supported by the current WindVane SDK version.

Input parameters

  • [string]api: the name of the API. Example: WVBase and WVMotion.

  • [string]method: (optional) the method of the API. Example: isWindVaneSDK and copyToClipboard. If you do not specify the method, this API returns only information on whether the current WindVane SDK version supports the API that you specified.

Callback parameters

  • [boolean]canUse: true indicates that the API is supported by the current WindVane SDK version, and false indicates that the API is not supported by the current WindVane SDK version.

var params = {
        api: 'WVMotion',
        method: 'vibrate'
};
window.WindVane.call('WVBase', 'canIUse', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVMiniApp.close

Closes the miniapp.

Input parameters:

None.

Callback parameters:

None.

window.WindVane.call('WVMiniApp', 'close', {}, function(e) {
  			alert('success');
}, function(e) {
  			alert('failure');
});