JSAPI overview

更新时间:
复制 MD 格式

This topic describes the features and usage of Windvane Mini Program JSAPIs.

Basics

Name

Description

Android

iOS

WVBase.checkWindVaneSDK

Compares a specified version number with the current WindVaneSDK version number.

N

Y

WVBase.copyToClipboard

Copies the specified text to the clipboard.

Y

Y

WVBase.isInstall

Checks whether a specified application is installed.

Y

Y

WVBase.isAppsInstalled

Checks whether multiple specified applications are installed.

Y

Y

WVBase.isWindVaneSDK

Gets the current version of the WindVaneSDK.

Y

Y

WVBase.notify

Triggers an event with a specified name and parameters in the document.

N

Y

WVBase.openBrowser

Opens a new Safari window for a specified URL.

N

Y

WVBase.setBackgroundColor

Sets the background color of the WebView.

N

Y

WVBase.canIUse

Checks whether the current version supports a specified API.

Y

Y

WVMiniApp.close

Closes the miniapp.

Y

Y

Routing

Name

Description

Android

iOS

WVNavigator.pop

Exits the current interface.

Y

Y

WVNavigator.push

Opens a new miniapp interface.

Y

Y

Interaction feedback

  • Universal components

Name

Description

Android

iOS

WVUI.showLoadingBox

Displays a loading box.

Y

Y

WVUI.hideLoadingBox

Hides the loading box.

Y

Y

WVUI.hideKeyboard

Hides the keyboard.

Y

Y

  • Prompts

Name

Description

Android

iOS

WVUIToast.toast

Displays a toast, which is a simple prompt shown in the center of the screen.

Y

Y

  • Dialog boxes

Name

Description

Android

iOS

WVUIDialog.alert

Displays an alert box.

Y

Y

WVUIDialog.confirm

Displays a confirmation box.

Y

Y

WVUI.enableAlertBeforeUnload

Enables a confirmation dialog box when a user returns from a miniapp page. After this is enabled, if a user presses the back button to close the miniapp page, a dialog box appears asking for confirmation to leave.

Y

Y

WVUI.disableAlertBeforeUnload

Close the confirmation dialog box for navigating back from a miniapp page.

Y

Y

WVUIDialog.prompt

Displays a dialog box that prompts the user to enter text.

Y

Y

WVUIDialog.showAuthGuide

Displays a dialog box with images and text from the permission guide module to guide users to enable the required permissions.

Y

Y

WVUIDatePicker.show

Displays a date picker. You can set a default date. If no date is set, the current date is used by default.

Y

Y

  • List of Actions

Name

Description

Android

iOS

WVUIActionSheet.show

Displays an ActionSheet, which is a list of actions shown at the bottom of the screen.

Y

Y

  • Navigation bar

Name

Description

Android

iOS

WVNavigationBar.update

Dynamically sets the title bar of the current page.

Y

Y

WVNavigationBar.getHeight

Gets the height of the miniapp title bar.

Y

Y

Multimedia

  • Image saving

Name

Description

Android

iOS

WVImage.saveImage

Saves an image from an HTTP or HTTPS address, or in base64 format, to the photo album.

Y

Y

  • Video

Name

Description

Android

iOS

WVVideo.chooseVideo

Records a video or selects a video from the phone's photo album.

Y

Y

WVVideo.saveVideoToPhotosAlbum

Saves a video to the system photo album.

Y

Y

  • Audio

Name

Description

Android

iOS

WVAudio.playSystemSound

Plays a specified system sound.

N

Y

  • Camera

Name

Description

Android

iOS

WVCamera.takePhoto

Lets users take a photo with the camera or select a photo from the album. After a photo is obtained, you can specify whether to automatically upload it. The upload protocol must be implemented on the native client.

Y

Y

WVCamera.confirmUploadPhoto

Confirms the photo upload.

Y

Y

Cache

Name

Description

Android

iOS

WVStorage.setItem

Stores data in the local cache with a specified key.

Y

Y

WVStorage.getItem

Asynchronously gets the content of a specified key from the local cache.

Y

Y

WVStorage.removeItem

Deletes the content of a specified key from the local cache.

Y

Y

WVStorage.clearStorage

Asynchronously purges the cache.

Y

Y

WVStorage.clearStorageSync

Synchronously purges the cache.

Y

Y

Files

Name

Description

Android

iOS

WVFile.write

Writes the specified file content to the disk.

Y

Y

WVFile.read

Reads the content of a specified file.

Y

Y

WVFile.getFileInfo

Gets file information.

Y

Y

WVFile.downloadFile

Downloads a file resource to the local device.

Y

Y

WVFile.uploadFile

Uploads a file to a specified server URL.

Y

Y

Geolocation

Name

Description

Android

iOS

WVLocation.getLocation

Gets the current geographical location.

Y

Y

WVLocation.searchLocation

Searches for the latitude and longitude of a given address.

N

Y

Cross-domain

Name

Description

Android

iOS

WVCookie.read

Reads all cookies for a specified URL.

Y

Y

WVCookie.write

Writes a specified cookie.

Y

Y

Device

  • System info

Name

Description

Android

iOS

WVSystem.getSystemInfo

Gets the phone's system information.

Y

Y

WVSystem.getSystemInfoSync

Synchronously gets the phone's system information.

Y

Y

  • Device environment detection

Name

Description

Android

iOS

WVNativeDetector.isSimulator

Checks whether the current environment is an emulator.

Y

Y

WVNativeDetector.getCurrentUsage

Gets the current CPU and memory usage information.

Y

Y

WVNativeDetector.getDeviceYear

Gets the release date of the device, which can be used to estimate device performance. For iOS, the release date can be obtained with high accuracy. For Android, this can be used to estimate device performance.

Y

Y

WVNativeDetector.getModelInfo

Gets information such as the device model.

Y

Y

WVNativeDetector.getSafeAreaInsets

Gets the safe area information for the current page. This applies only to full-screen pages.

N

Y

  • Network status

Name

Description

Android

iOS

WVNetwork.getNetworkType

Gets the current network type.

Y

Y

  • Screen

Name

Description

Android

iOS

WVScreen.getOrientation

Returns the display orientation (landscape or portrait) of the current Activity/ViewController.

Y

Y

WVScreen.setOrientation

Sets the display orientation (landscape or portrait) of the current ViewController/Activity.

Y

Y

WVScreen.setScreenBrightness

Sets the screen brightness.

Y

Y

WVScreen.getScreenBrightness

Gets the screen brightness.

Y

Y

  • Screenshot

Name

Description

Android

iOS

WVScreenCapture.capture

Captures the visible part of the current WebView as an image.

Y

Y

  • Motion detection

Name

Description

Android

iOS

WVMotion.listenBlow

Enables the listener for the blowing action.

Y

Y

WVMotion.stoplistenBlow

Stops the listener for the blowing action.

Y

Y

WVMotion.listenGyro

Enables or disables the gyroscope listener.

Y

Y

WVMotion.listeningShake

Enables or disables the shake listener.

Y

Y

WVMotion.vibrate

Makes the phone vibrate.

Y

Y

WVMotion.startAccelerometer

Starts listening for accelerometer data.

Y

Y

WVMotion.stopAccelerometer

Stops listening for accelerometer data.

Y

Y

WVMotion.startCompass

Starts listening for compass data.

Y

Y

WVMotion.stopCompass

Stops listening for compass data.

Y

Y

  • Beep

Name

Description

Android

iOS

WVNotification.beep

Makes the phone beep.

Y

Y

  • Phone calls

Name

Description

Android

iOS

WVCall.dial

Opens the dial-up keyboard.

Y

Y

WVCall.call

You can make a call directly.

Y

Y

  • Application info

Name

Description

Android

iOS

WVApplication.appState

Returns the state of the current application (whether it is in the foreground).

N

Y

WVApplication.getNotificationSettings

Returns the notification status of the current application.

N

Y

WVApplication.openSettings

Opens the settings page for the current application.

N

Y

  • Address book

Name

Description

Android

iOS

WVContacts.askAuth

Requests permission to access the address book.

N

Y

WVContacts.authStatus

Gets the current access permission status for the address book.

N

Y

WVContacts.choose

Opens the address book list. After a user selects a contact, the contact's name and phone number are returned to the H5 client.

Y

Y

WVContacts.find

Finds a contact in the address book by a specified name and phone number.

Y

Y

WVContacts.addPhoneContact

Adds a contact.

Y

Y

  • QR code scanning

Name

Description

Android

iOS

WVScan.scan

Scans a QR code.

Y

Y

  • Device battery

Name

Description

Android

iOS

WVBattery.getBatteryInfo

Asynchronously gets the battery level.

Y

Y

WVBattery.getBatteryInfoSync

Synchronously gets the battery level.

Y

Y

  • Bluetooth

Name

Description

Android

iOS

WVBluetooth.requestAuthorization

Requests Bluetooth-related permissions and enables Bluetooth.

Y

Y

WVBluetooth.scan

Scans for Bluetooth Low Energy (LE) devices.

Y

Y

WVBluetooth.stopScan

Stops scanning for Bluetooth devices.

Y

Y

WVBluetooth.connect

Connects to a Bluetooth device at a specified Bluetooth address.

Y

Y

WVBluetooth.disconnect

Disconnects from a connected Bluetooth device.

Y

Y

WVBluetooth.getServices

Starts searching for the services of a Bluetooth LE device.

Y

Y

WVBluetooth.getCharacteristics

Gets all the characteristics of a Bluetooth LE device.

Y

Y

WVBluetooth.writeValue

Writes a specified characteristic value to a connected Bluetooth LE device.

Y

Y

WVBluetooth.readValue

Reads a specified characteristic value from a connected Bluetooth LE device.

Y

Y

WVBluetooth.startNotifications

Enables notifications for characteristic value changes.

Y

Y

WVBluetooth.stopNotifications

Disables notifications for characteristic value changes.

Y

Y

Communication

Name

Description

Android

iOS

WVStandardEventCenter.postNotificationToNative

Sends an event from the miniapp client to the native client. The event name can be any name agreed upon with the native service.

Y

Y

Information reporting

Name

Description

Android

iOS

WVReportor.reportDomLoad

Reports the time to first byte and the DomLoad event time for the current page.

Y

Y

WVReportor.reportError

Reports JavaScript errors on the current page.

Y

Y

Obtain account information

Name

Description

Android

iOS

WVUser.getUserInfo

Gets the information of the currently logged-on user. The miniapp container uses this information for authorization management.

Y

Y

Other features

Name

Description

Android

iOS

WindVaneReady

After a page is loaded, WindVane triggers a WindVaneReady event. The page can listen for this event to get the page load status.

Y

Y

Background

When the application is switched to the background, such as by switching applications or opening the notification bar, WindVane triggers the WV.Event.APP.Background event. The page can listen for this event to know that the application has been moved to the background.

Y

Y

Active

When the application is switched back from the background, WindVane triggers the WV.Event.APP.Active event. The page can listen for this event to know that the application has been activated.

Y

Y

Pull Refresh

By default, WindVane for iOS automatically enables pull-to-refresh. This feature is enabled by default and must be manually disabled if it is not needed.

N

Y

Infinite Scroll

When a page is scrolled to the bottom, you can use infinite scroll to dynamically load new content. This feature is disabled by default and must be manually enabled if it is needed.

N

Y