This topic describes the functions of JavaScript APIs of WindVane miniapp and how to use the APIs.
WVBase
API | Function | Android | iOS |
WVBase.copyToClipboard | Copies the specified text to the clipboard. | Supported | Supported |
WVBase.isInstall | Checks whether the specified app is installed. | Supported | Supported |
WVBase.isAppsInstalled | Checks whether the specified apps are installed. | Supported | Supported |
WVBase.notify | Triggers the specified event in | Not supported | Supported |
WVBase.openBrowser | Opens a new Safari page to access a specified URL. | Not supported | Supported |
WVBase.setBackgroundColor | Configures the background color of WebView. | Not supported | Supported |
WVBase.canIUse | Checks whether an API is supported by the current WindVane SDK version. | Supported | Supported |
WVMiniApp.close | Closes the miniapp. | Supported | Supported |
Navigation
API | Function | Android | iOS |
WVNavigator.pop | Closes the current page. | Supported | Supported |
WVNavigator.push | Opens a new page in the miniapp. | Supported | Supported |
Interactions
API | Function | Android | iOS |
WVUI.showLoadingBox | Displays the loading message. | Supported | Supported |
WVUI.hideLoadingBox | Hides the loading message. | Supported | Supported |
WVUI.hideKeyboard | Hides the keyboard. | Supported | Supported |
API | Function | Android | iOS |
WVUIToast.toast | Displays a toast in the center of the screen. | Supported | Supported |
API | Function | Android | iOS |
WVUIDialog.alert | Displays a warning message. | Supported | Supported |
WVUIDialog.confirm | Displays a confirmation message. | Supported | Supported |
WVUIDialog.enableAlertBeforeUnload | Displays a confirmation message when a user attempts to close the miniapp by clicking the Back button. | Supported | Supported |
WVUIDialog.disableAlertBeforeUnload | Does not display a confirmation message when a user attempts to close the miniapp by clicking the Back button. | Supported | Supported |
WVUIDialog.prompt | Displays a text box where a user can input text. | Supported | Supported |
WVUIDialog.showAuthGuide | Displays a dialog box to guide the user in granting permissions. The dialog box provides text and illustrations. | Supported | Supported |
WVUIDatePicker.show | Displays a date picker. You can set the default date. If you do not set a default date, the current date is used. | Supported | Supported |
API | Function | Android | iOS |
WVUIActionSheet.show | Displays an action sheet. A list of buttons is displayed at the bottom of the screen. | Supported | Supported |
API | Function | Android | iOS |
WVNavigationBar.update | Configures the navigation bar of the current page. | Supported | Supported |
WVNavigationBar.getHeight | Obtains the height of the navigation bar in the miniapp. | Supported | Supported |
Multimedia
API | Function | Android | iOS |
WVImage.saveImage | Saves images from HTTP or HTTPS URLs or Base64-encoded images to albums. | Supported | Supported |
API | Function | Android | iOS |
WVVideo.chooseVideo | Shoots a video or selects a video from an album. | Supported | Supported |
WVVideo.saveVideoToPhotosAlbum | Saves an online video to a local album. | Supported | Supported |
API | Function | Android | iOS |
WVAudio.playSystemSound | Plays the specified system sound. | Not supported | Supported |
API | Function | Android | iOS |
WVCamera.takePhoto | Takes a photo or selects a photo from the album. Users can determine whether to enable automatic photo upload. The automatic photo upload feature needs to be implemented in the native application. | Supported | Supported |
WVCamera.confirmUploadPhoto | Confirms the photo upload. | Supported | Supported |
Cache
API | Function | Android | iOS |
WVStorage.setItem | Sets the value of a specified key in the local cache. | Supported | Supported |
WVStorage.getItem | Obtains the value of a specified key from the local cache. | Supported | Supported |
WVStorage.removeItem | Removes the value of a specified key from the local cache. | Supported | Supported |
WVStorage.clearStorage | Asynchronously clears the local data cache. | Supported | Supported |
WVStorage.clearStorageSync | Synchronously clears the local data cache. | Supported | Supported |
File
API | Function | Android | iOS |
WVFile.write | Writes the specified content to a disk. | Supported | Supported |
WVFile.read | Reads the content of a specified file. | Supported | Supported |
WVFile.getFileInfo | Obtains information about a file. | Supported | Supported |
WVFile.downloadFile | Downloads a file from a specified URL. | Supported | Supported |
WVFile.uploadFile | Uploads a file to a specified server URL. | Supported | Supported |
WVFile.chooseFiles | choose local file upload | Supported | Supported |
WVFile.getDataByFilePath | get data by local file path | Supported | Supported |
Geographic location
API | Function | Android | iOS |
WVLocation.getLocation | Obtains the current geographic location. | Supported | Supported |
WVLocation.searchLocation | Searches for the specified address and obtains the latitude and longitude. | Not supported | Supported |
Cookie
API | Function | Android | iOS |
WVCookie.read | Reads all cookies from a specified URL. | Supported | Supported |
WVCookie.write | Writes a cookie. | Supported | Supported |
Device
API | Function | Android | iOS |
WVSystem.getSystemInfo | Obtains the system information of a device. | Supported | Supported |
WVSystem.getSystemInfoSync | Synchronously obtains the system information of a device. | Supported | Supported |
API | Function | Android | iOS |
WVNativeDetector.isSimulator | Checks whether the device is simulated. | Supported | Supported |
WVNativeDetector.getCurrentUsage | Obtains the current CPU utilization and memory usage. | Supported | Supported |
WVNativeDetector.getDeviceYear | Obtains the release year of the device. You can learn about the device performance based on its release year. You can easily identify the model of an iOS device and determine whether its performance can meet your business requirements. For an Android device, you can determine whether its performance is adequate only based on its release year. | Supported | Supported |
WVNativeDetector.getModelInf | Obtains the device information, such as the device model. | Supported | Supported |
WVNativeDetector.getSafeAreaInsets | Obtains the safe area information of the current view. This API is available only for full screen pages. | Not supported | Supported |
API | Function | Android | iOS |
WVNetwork.getNetworkType | Obtains the current network type. | Supported | Supported |
API | Function | Android | iOS |
WVScreen.getOrientation | Obtains the display orientation (landscape or portrait) of the current activity or view controller. | Supported | Supported |
WVScreen.setOrientation | Sets the display orientation (landscape or portrait) of the current activity or view controller. | Supported | Supported |
WVScreen.setScreenBrightness | Sets the screen brightness. | Supported | Supported |
WVScreen.getScreenBrightness | Obtains the screen brightness. | Supported | Supported |
API | Function | Android | iOS |
WVScreenCapture.capture | Takes a screenshot of the visible content in WebView. | Supported | Supported |
API | Function | Android | iOS |
WVMotion.listenBlow | Monitors blow gestures. | Supported | Supported |
WVMotion.stopListenBlow | Stops monitoring blow gestures. | Supported | Supported |
WVMotion.listenGyro | Enables or disables monitoring of the gyroscope. | Supported | Supported |
WVMotion.listeningShake | Enables or disables monitoring of shake gestures. | Supported | Supported |
WVMotion.vibrate | Makes the phone vibrate. | Supported | Supported |
WVMotion.startAccelerometer | Monitors acceleration data. | Supported | Supported |
WVMotion.stopAccelerometer | Stops monitoring acceleration data. | Supported | Supported |
WVMotion.startCompass | Monitors compass data. | Supported | Supported |
WVMotion.stopCompass | Stops monitoring compass data. | Supported | Supported |
API | Function | Android | iOS |
WVNotification.beep | Makes the phone beep. | Supported | Supported |
API | Function | Android | iOS |
WVCall.dial | Displays the telephone keypad. | Supported | Supported |
WVCall.call | Makes a phone call directly. | Supported | Supported |
API | Function | Android | iOS |
WVApplication.appState | Returns the status of the application. The status indicates whether the application is running in the foreground. | Not supported | Supported |
WVApplication.getNotificationSettings | Returns the notification settings of the application. | Not supported | Supported |
WVApplication.openSettings | Displays the settings page of the application. | Not supported | Supported |
API | Function | Android | iOS |
WVContacts.askAuth | Requests access to contacts. | Not supported | Supported |
WVContacts.authStatus | Checks whether access permissions on contacts are granted. | Not supported | Supported |
WVContacts.choose | Displays contacts. After a user selects a contact, the name and phone number of the contact are returned to the HTML5 page. | Supported | Supported |
WVContacts.find | Searches for a contact by specifying the name and phone number. | Supported | Supported |
WVContacts.addPhoneContact | Adds a contact. | Supported | Supported |
API | Function | Android | iOS |
WVScan.scan | Enables the scanning feature. | Supported | Supported |
API | Function | Android | iOS |
WVBattery.getBatteryInfo | Asynchronously obtains the battery level. | Supported | Supported |
WVBattery.getBatteryInfoSync | Synchronously obtains the battery level. | Supported | Supported |
API | Function | Android | iOS |
WVBluetooth.requestAuthorization | Requests Bluetooth permissions and enables Bluetooth. | Supported | Supported |
WVBluetooth.scan | Searches for Bluetooth Low Energy (BLE) devices. | Supported | Supported |
WVBluetooth.stopScan | Stops searching for BLE devices. | Supported | Supported |
WVBluetooth.connect | Connects the device on which the application runs to a Bluetooth device with a specified Bluetooth address. | Supported | Supported |
WVBluetooth.disconnect | Disconnects the connected Bluetooth devices. | Supported | Supported |
WVBluetooth.getServices | Starts to search for the BLE device services. | Supported | Supported |
WVBluetooth.getCharacteristics | Obtains values of all characteristics of BLE devices. | Supported | Supported |
WVBluetooth.writeValue | Sets the value of a specified characteristic to a connected BLE device. | Supported | Supported |
WVBluetooth.readValue | Reads the value of a specified characteristic from a connected BLE device. | Supported | Supported |
WVBluetooth.startNotifications | Enables the notification of characteristic value changes. | Supported | Supported |
WVBluetooth.stopNotifications | Disables the notification of characteristic value changes. | Supported | Supported |
Communication
API | Function | Android | iOS |
WVStandardEventCenter.postNotificationToNative | Sends events from the miniapp to a native application. The event name can be modified based on the business requirements of the native application. | Supported | Supported |
Other features
API | Function | Android | iOS |
WindVaneReady | When a page is loaded, WindVane triggers the WindVaneReady event. The page can listen for this event to obtain the page loading status. | Supported | Supported |
Background | When the application starts to run in the background, for example, when a user switches to another app or opens the notification bar, WindVane triggers the WV.Event.APP.Background event. The page can listen for this event to determine whether the application switches to the background. | Supported | Supported |
Active | When the application switches from the background to the foreground, WindVane triggers the WV.Event.APP.Active event. The page can listen for this event to determine whether the application is active. | Supported | Supported |