This topic describes the functions provided by JavaScript APIs of uni-app miniapps and how to use the APIs. You can refer to this topic when you use JavaScript APIs of uni-app miniapps.
For more information about the JavaScript APIs, visit uni-app official website. Only the JavaScript APIs listed in this topic are applicable to uni-app miniapps hosted in superapps. Miniapps that call such JavaScript APIs can be pushed to your own superapp platform.
Base
API | Description | References |
uni.base64ToArrayBuffer | Converts a Base64 string to an ArrayBuffer object. | |
uni.arrayBufferToBase64 | Converts an ArrayBuffer object to a Base64 string. | |
uni.getLaunchOptionsSync | Obtains the parameters for cold startup. | |
uni.getEnterOptionsSync | Obtains the parameters for hot startup. | |
uni.addInterceptor | Adds an interceptor. | |
uni.removeInterceptor | Removes an interceptor. | |
uni.canIUse | Determines whether the APIs, callbacks, parameters, and components of the app are available in the current version. |
Network
Request initiation
API | Description | References |
uni.request | Initiates a network request. |
Upload/Download
API | Description | References |
uni.uploadFile | Uploads local resources to your server. The client initiates an HTTP | |
uni.downloadFile | Downloads a file to your local device. The client directly initiates an |
WebSocket
API | Description | References |
uni.connectSocket | Creates a WebSocket connection. | |
uni.onSocketOpen | Listens to WebSocket connection opening events. | |
uni.onSocketError | Listens to WebSocket error events. | |
uni.sendSocketMessage | Sends data over a WebSocket connection. Data can be sent only after uni.connectSocket is called and the uni.onSocketOpen callback is completed. | |
uni.onSocketMessage | Listens to events that are triggered when messages from the server are received over a WebSocket connection. | |
uni.closeSocket | Closes a WebSocket connection. | |
uni.onSocketClose | Listens to WebSocket connection closing events. |
SocketTask
API | Description | References |
SocketTask.onMessage | Listens to events that are triggered when messages from the server are received over a WebSocket connection. | |
SocketTask.send | Sends data over a WebSocket connection. | |
SocketTask.close | Closes a WebSocket connection. | |
SocketTask.onOpen | Listens to WebSocket connection opening events. | |
SocketTask.onClose | Listens to WebSocket connection closing events. | |
SocketTask.onError | Listens to WebSocket error events. |
Page routing
API | Description | References |
uni.navigateTo | Keeps the current page open and redirects to the specified page in the app. You can use uni.navigateBack to return to the original page. | |
uni.redirectTo | Closes the current page and redirects to the specified page in the app. | |
uni.reLaunch uni.reLaunch | Closes all pages and redirects to the specified page in the app. | |
uni.switchTab uni.switchTab | Redirects to the specified TabBar page and closes all other non-TabBar pages. | |
uni.navigateBack uni.navigateBack | Closes the current page and goes back to the previous page (or a specific page in the page stack). You can obtain the current page stack by using getCurrentPages() to determine which page to go back to. | |
uni.preloadPage uni.preloadPage | Preloads pages. Page pre-loading is a performance optimization technology. The preloaded pages can be opened faster. |
EventChannel
API | Description | References |
EventChannel.emit | Triggers an event. | |
EventChannel.off | Cancels listening to an event. | |
EventChannel.on | Continuously listens to an event. | |
EventChannel.once | Listens to an event once. After the event is triggered, it becomes invalid. |
Window animation
The animations for opening and closing a window can be configured by using APIs, components, or pages.json. The use of APIs or components take precedence over the use of pages.json. For more information, see Window animation.
Inter-page communication
API | Description | References |
uni.$emit | Triggers global custom events. Additional parameters are passed to the listener callback function. | |
uni.$on | Listens to global custom events. The events are triggered by uni.$emit. The callback function receives the parameters passed into the event trigger function. | |
uni.$once | Listens to global custom events. The events are triggered by uni.$emit, but are triggered only once. The listener is removed after the events are triggered. | |
uni.$off | Removes the global custom event listener. |
subNVues native subform
API | Description | References |
uni.getSubNVueById | Obtains an instance of the subNVues native subform by ID. | |
uni.getCurrentSubNVue | Obtains an instance of the current subNVues native subform in the nvue page code of the subNVues form. | |
subNVue.show | Shows a native subform. | |
subNVue.hide | Hides a native subform. |
Data caching
API | Description | References |
uni.setStorage | Stores data in the specified key in the local cache. This asynchronous operation will overwrite the original content of the key. | |
uni.setStorageSync | Stores data in the specified key in the local cache. This synchronous operation will overwrite the original content of the key. | |
uni.getStorage | Asynchronously obtains the content of the specified key from the local cache. | |
uni.getStorageSync | Synchronously obtains the content of the specified key from the local cache. | |
uni.getStorageInfo | Asynchronously obtains information about the current storage. | |
uni.getStorageInfoSync | Synchronously obtains information about the current storage. | |
uni.removeStorage | Asynchronously removes the specified key from the local cache. | |
uni.removeStorageSync | Synchronously removes the specified key from the local cache. | |
uni.clearStorage | Asynchronously clears the locally cached data. | |
uni.clearStorageSync | Synchronously clears the locally cached data. |
Location
Location acquisition
API | Description | References |
uni.getLocation | Obtains the current geographic location and speed. | |
uni.chooseLocation | Opens a map and selects a location. | |
plus.geolocation.getCurrentPosition | Obtains the current location of the device. |
Location update
API | Description | References |
uni.onLocationChange | Listens to real-time geolocation change events. This API needs to be used in combination with uni.startLocationUpdate or uni.startLocationUpdateBackground. | |
uni.offLocationChange | Cancels listening to real-time geolocation change events and stops receiving messages in both the foreground and background. | |
uni.onLocationChangeError | Listens to location change errors. This function is triggered when the call to the continuous positioning API fails. | |
uni.offLocationChangeError | Unregisters the callback for location update errors. | |
uni.startLocationUpdate | Enables the reception of location messages when the miniapp enters the foreground. | |
uni.stopLocationUpdate | Cancels listening to real-time geolocation change events and stops receiving messages in both the foreground and background. | |
uni.startLocationUpdateBackground | Starts listening to real-time geolocation change events and enables the reception of real-time geolocation information when the miniapp enters the foreground or background. | |
plus.geolocation.watchPosition | Listens to device location changes. | |
plus.geolocation.clearWatch | Cancels listening to device location changes. |
Map component control
API | Description | References |
uni.createMapContext | Creates and returns a mapContext object. In a custom component, the "this" custom component instance is passed as the second parameter to manage the <map> component in this component. | |
plus.maps.openSysMap | Calls a third-party app for navigation. | |
plus.maps.create | Creates a Map object. | |
plus.maps.getMapById | Finds a created Map object. |
Media
Image
API | Description | References |
uni.chooseImage | Selects an image from the local album or takes a photo. | |
uni.previewImage | Previews an image. | |
uni.closePreviewImage | Closes the image preview. | |
uni.getImageInfo | Obtains image information. | |
uni.saveImageToPhotoAlbum | Saves an image to the local album. | |
uni.compressImage | Compresses images to different quality levels. | |
plus.gallery.pick | Selects an image or video from the local album. | |
plus.gallery.save | Saves a file to the local album. |
Camera
API | Description | References |
plus.camera.getCamera | Obtains a camera object. |
Recording
API | Description | References |
ni.getRecorderManager | Obtains a globally unique recorderManager object. | |
plus.audio.getRecorder | Obtains the recorder of the current device. | |
plus.audio.createPlayer | Creates an audio player. |
Background audio
API | Description | References |
uni.getBackgroundAudioManager | Obtains a globally unique backgroundAudioManager object. |
Audio component control
API | Description | References |
uni.createInnerAudioContext | Creates and returns an innerAudioContext object. |
Video
API | Description | References |
uni.chooseVideo https://en.uniapp.dcloud.io/api/media/video.html | Selects a video from the local album or takes a video and returns the temporary path of the video. | |
uni.saveVideoToPhotosAlbum | Saves a video to the local album. | |
uni.getVideoInfo | Obtains details about a video. | |
uni.compressVideo | Compresses a video. | |
plus.video.createVideoPlayer | Creates a VideoPlayer object. | |
plus.video.createLivePusher | Creates a LibePusher object. | |
plus.video.getVideoPlayerById | Finds a created VideoPlayer object. | |
plus.video.getLivePusherById | Finds a created LibePusher object. |
Video component control
API | Description | References |
uni.createVideoContext | Creates and returns a videoContext object. In a custom component, the "this" custom component instance is passed as the second parameter to manage the <video> component in the component. |
Device
System
API | Description | References |
uni.getSystemInfo | Asynchronously obtains system information. | |
uni.getSystemInfoSync | Synchronously obtains system information. | |
uni.getDeviceInfo | Obtains the basic information about a device. | |
uni.getWindowInfo | Obtains window information. | |
uni.getSystemSetting | Obtains device settings. | |
uni.openAppAuthorizeSetting | Redirects to the app authorization management page. | |
plus.device.beep | Makes a device to beep. | |
plus.device.getInfo | Obtains device information. | |
plus.device.getOAID | Obtains the Open Anonymous Device Identifier (OAID) of a device. | |
plus.device.getVAID | Obtains the Developer Anonymous Device Identifier (VAID) of a device. | |
plus.device.getAAID | Obtains the Application Anonymous Device Identifier (AAID) of a device. | |
plus.device.getDeviceId | Obtains the DCloud anonymous device identifier of a device. | |
plus.device.getVolume | Obtains the system volume of a device. | |
plus.device.setVolume | Sets the system volume of a device. | |
plus.device.isWakelock | Determines whether the app remains awake. | |
plus.device.setWakelock | Sets whether to keep the app awake. | |
plus.device.virate | Makes a device to vibrate. | |
plus.navigator.checkPermission | Checks the permissions of the runtime environment. | |
plus.navigator.closeSplashscreen | Closes the app splash screen. | |
plus.navigator.hasNotchInScreen | Checks whether a device has a notch in the screen. | |
plus.navigator.hasSplashscreen | Checks whether the app splash screen is closed. | |
plus.navigator.updateSplashscreen | Updates the app splash screen. | |
plus.navigator.createShortcut | Creates an app shortcut. | |
plus.navigator.hasShortcut | Checks whether app shortcuts exist. | |
plus.navigator.hideSystemNavigation | Hides system virtual keys. | |
plus.navigator.showSystemNavigation | Shows system virtual keys. | |
plus.navigator.isBackground | Determines whether the current app is switched to the background. | |
plus.navigator.isFullscreen | Determines whether the app is in full-screen mode. | |
plus.navigator.isLogs | Determines whether the app outputs logs. | |
plus.navigator.isRoot | Determines whether the device running the app is rooted. | |
plus.navigator.isSimulator | Determines whether the current app is running in a simulator. | |
plus.navigator.setFullscreen | Sets whether to display the app in full screen. | |
plus.navigator.setLogs | Sets whether to allow the app to output logs. | |
plus.navigator.setStatusBarBackground | Sets the background color of the system status bar. | |
plus.navigator.getStatusBarBackground | Obtains the background color of the system status bar. | |
plus.navigator.setStatusBarStyle | Sets the style of the system status bar. | |
plus.navigator.getStatusBarStyle | Obtains the style of the system status bar. | |
plus.navigator.getStatusbarHeight | Obtains the height of the system status bar. | |
plus.navigator.isImmersedStatusbar | Determines whether the status bar is immersive. | |
plus.navigator.setUserAgent | Sets the userAgent property. | |
plus.navigator.getUserAgent | Obtains the userAgent property. | |
plus.navigator.setCookie | Sets cookie values. | |
plus.navigator.getCookie | Obtains cookie values. | |
plus.navigator.removeAllCookie | Deletes all cookie values for the app. | |
plus.navigator.removeCookie | Deletes app cookies. | |
plus.navigator.removeSessionCooki | Deletes all session cookie values for the app. | |
plus.navigator.getSafeAreaInsets | Obtains the safe area insets for the app. | |
plus.navigator.getOrientation | Obtains the screen orientation of the app. | |
plus.navigator.getUIStyle | Obtains the UI style to determine whether the dark mode is used. | |
plus.navigator.getSignature | Obtains the signature of the app. | |
plus.orientation.getCurrentOrientation | Obtains the orientation information of the current device around three axes: alpha, beta, and gamma. | |
plus.orientation.watchOrientation | Listens to device orientation changes. | |
plus.orientation.clearWatch | Cancels listening to device orientation changes. | |
plus.proximity.getCurrentProximity | Obtains the proximity information of the current device. | |
plus.proximity.watchProximity | Listens to device proximity changes. | |
plus.proximity.clearWatch | Cancels listening to device proximity changes. | |
plus.runtime.agreePrivacy | Specifies that the user agrees to the privacy policy. | |
plus.runtime.disagreePrivacy | Specifies that the user does not agree to the privacy policy. | |
plus.runtime.isAgreePrivacy | Checks whether the user agrees to the privacy policy. | |
plus.runtime.showPrivacyDialog | Shows the privacy dialog box. | |
plus.runtime.getProperty | Obtains information about the specified app. | |
plus.runtime.install | Installs the app. | |
plus.runtime.quit | Quits the app. | |
plus.runtime.restart | Restarts the current app. | |
plus.runtime.setBadgeNumber | Sets the badge number on the app icon. | |
plus.runtime.openURL | Calls a third-party app to open the specified URL. | |
plus.runtime.openWeb | Uses a built-in WebView to open a URL. | |
plus.runtime.openFile | Calls a third-party app to open the specified file. | |
plus.runtime.processDirectPage | Processes the parameter that is used to specify a direct page URL. | |
plus.runtime.launchApplication | Calls a third-party app. | |
plus.runtime.isApplicationExist | Checks whether a third-party app already exists. | |
plus.runtime.isCustomLaunchPath | Determines whether to customize the URL for loading the app startup page. |
Network status
API | Description | References |
uni.getNetworkType | Obtains the network type. | |
uni.onNetworkStatusChange | Listens to network status changes. You can use uni.offNetworkStatusChange to cancel the listening. | |
uni.offNetwokrStatusChange | Cancels listening to network status changes. |
System theme
API | Description | References |
uni.onThemeChange | Listens to changes in the system theme status. | |
uni.offThemeChange | Cancels listening to changes in the system theme status. |
Accelerometer
API | Description | References |
uni.onAccelerometerChange | Listens to accelerometer data at a frequency of 5 times per second. Listening starts automatically after the API is called. To stop listening, call uni.offAccelerometer. | |
uni.offAccelerometerChange | Cancels listening to accelerometer data. | |
uni.startAccelerometer | Starts listening to accelerometer data. | |
uni.stopAccelerometer | Stops listening to accelerometer data. | |
plus.accelerometer.getCurrentAcceleration | Obtains the accelerometer information of the current device. | |
plus.accelerometer.watchAcceleration | Listens to the accelerometer data of a device. | |
plus.clearWatch | Cancels listening to the accelerometer data of a device. |
Compass
API | Description | References |
uni.onCompassChange | Listens to compass data at a frequency of 5 times per second. Listening starts automatically after the API is called. To stop listening, call uni.offCompassChange. | |
uni.offCompassChange | Cancels listening to compass data. | |
uni.startCompass | Starts listening to compass data. | |
uni.stopCompass | Stops listening to compass data. |
Phone call
API | Description | References |
uni.makePhoneCall | Makes a phone call. | |
plus.device.dial | Makes a phone call. |
Code scanning
API | Description | References |
uni.scanCode | Scans a code and returns the result. | |
plus.barcode.scan | Scans the barcode in an image. | |
plus.barcode.create | Creates a barcode recognition control object. | |
plus.barcode.getBarcodeById | Finds a barcode recognition control object. |
Clipboard
API | Description | References |
uni.setClipboardData | Sets content on the system clipboard. | |
uni.getClipboardData | Obtains content from the system clipboard. |
Screen brightness
API | Description | References |
uni.setScreenBrightness | Sets the screen brightness. | |
uni.getScreenBrightness | Obtains the screen brightness. | |
uni.setKeepScreenOn | Sets whether to keep the screen steady on. This setting takes effect only for the current app. The setting becomes invalid after you exit the app. |
Screen capture
API | Description | References |
uni.onUserCaptureScreen | Listens to screen capture events initiated by users. Such events are triggered when users tap the screen capture button to take a screenshot. | |
uni.offUserCaptureScreen | Cancels listening to screen capture events initiated by users. | |
uni.setUserCaptureScreen | Enables or disables anti-screen capture. |
Vibration
API | Description | References |
uni.vibrate | Makes a phone to vibrate. | |
uni.vibrateLong | Makes a phone to vibrate for a long period of time (400 ms). | |
uni.vibrateShort | Makes a phone to vibrate for a short period of time (15 ms). |
Mobile contact
API | Description | References |
uni.addPhoneContact | Adds a contact or a piece of contact information to the mobile contacts. The user can write this form to the address book of the mobile phone by using either the "Add Contact" or "Add to Existing Contact" method. No such option is available in the app. | |
plus.contacts.getAddressBook | Obtains the address book. |
SMS or email
API | Description | References |
plus.messaging.createMessage | Creates a message object. | |
plus.messaging.sendMessage | Sends a message. |
Bluetooth
API | Description | References |
uni.openBluetoothAdapter | Initializes the Bluetooth module. | |
uni.startBluetoothDevicesDiscovery | Starts searching for nearby Bluetooth peripherals. This operation consumes a large amount of system resources. After searching for and connecting to a device, be sure to call the uni.stopBluetoothDevicesDiscovery method to stop searching. | |
uni.onBluetoothDeviceFound | Listens to new device discovery events. | |
uni.stopBluetoothDevicesDiscovery | Stops searching for nearby Bluetooth peripherals. If you have already found the device you need and do not need to continue searching, we recommend that you call this API to stop searching. | |
uni.onBluetoothAdapterStateChange | Listens to Bluetooth adapter status change events. | |
uni.getConnectedBluetoothDevices | Obtains devices in the connected state based on the UUIDs. | |
uni.getBluetoothDevices | Obtains all Bluetooth devices discovered during the active period of the Bluetooth module, including all devices that are already connected to the mobile phone. | |
uni.getBluetoothAdapterState | Obtains the status of the local Bluetooth adapter. | |
uni.closeBluetoothAdapter | Disables the Bluetooth module. Calling this method disconnects all established connections and releases system resources. We recommend that you call this method together with uni.openBluetoothAdapter after a Bluetooth process. | |
plus.bluetooth.closeBluetoothAdapter | Disables the Bluetooth module. | |
plus.bluetooth.getBluetoothAdapterState | Obtains the status of the Bluetooth adapter. | |
plus.bluetooth.getBluetoothDevices | Obtains the discovered Bluetooth devices. | |
plus.bluetooth.getConnectedBluetoothDevices | Obtains devices in the connected state based on the UUIDs. | |
plus.bluetooth.onBluetoothAdapterStateChange | Listens to Bluetooth adapter status change events. | |
plus.bluetooth.onBluetoothDeviceFound | Listens to new device discovery events. | |
plus.bluetooth.openBluetoothAdapter | Initializes the Bluetooth module. | |
plus.bluetooth.startBluetoothDevicesDiscovery | Starts searching for nearby Bluetooth devices. | |
plus.bluetooth.stopBluetoothDevicesDiscovery | Stops searching for nearby Bluetooth devices. |
BLE
API | Description | References |
uni.setBLEMTU | Sets the maximum transmission unit (MTU) of a Bluetooth Low Energy (BLE) device. You must call this API after the call to uni.createBLEConnection succeeds. The MTU can range from 22 to 512 bytes. This API is valid for Android 5.1 or later. | |
uni.writeBLECharacteristicValue | Writes binary data to the characteristic values of a BLE device. | |
uni.readBLECharacteristicValue | Obtains characteristic values from a BLE device in binary mode. | |
uni.onBLEConnectionStateChange | Listens to BLE connection status change events. | |
uni.onBLECharacteristicValueChange | Listens to changes of the characteristic values of a BLE device. | |
uni.notifyBLECharacteristicValueChange | Enables the function of notifying any characteristic value changes to a BLE device and subscribes to BLE characteristic values. | |
uni.getBLEDeviceServices | Obtains all the services provided by a Bluetooth device. | |
uni.getBLEDeviceRSSI | Obtains the signal strength of a Bluetooth device. | |
uni.getBLEDeviceCharacteristics | Obtains all the characteristic values of a service provided by a Bluetooth device. | |
uni.createBLEConnection | Connects to a BLE device. | |
uni.closeBLEConnection | Disconnects from a BLE device. | |
plus.bluetooth.closeBLEConnection | Disconnects from a BLE device. | |
plus.bluetooth.createBLEConnection | Connects to a BLE device. | |
plus.bluetooth.setBLEMTU | Sets the MTU of a BLE device. | |
plus.bluetooth.getBLEDeviceCharacteristics | Obtains all the characteristic values of a service provided by a Bluetooth device. | |
plus.bluetooth.getBLEDeviceRSSI | Obtains the signal strength of a Bluetooth device. | |
plus.bluetooth.getBLEDeviceServices | Obtains all the services provided by a Bluetooth device. | |
plus.bluetooth.notifyBLECharacteristicValueChange | Enables the function of notifying any characteristic value changes to a BLE device and subscribes to BLE characteristic values. | |
plus.bluetooth.onBLECharacteristicValueChange | Listens to changes of the characteristic values of a BLE device. | |
plus.bluetooth.onBLEConnectionStateChange | Listens to BLE connection status change events. | |
plus.bluetooth.readBLECharacteristicValu | Obtains characteristic values from a BLE device in binary mode. | |
plus.bluetooth.writeBLECharacteristicValue | Writes binary data to the characteristic values of a BLE device. |
iBeacon
API | Description | References |
uni.onBeaconServiceChange | Listens to iBeacon service status change events. | |
uni.onBeaconUpdate | Listens to iBeacon device update events. | |
uni.getBeacons | Obtains all discovered iBeacon devices. | |
uni.startBeaconDiscovery | Starts searching for nearby iBeacon devices. | |
uni.stopBeaconDiscovery | Stops searching for nearby iBeacon devices. | |
plus.ibeacon.startBeaconDiscovery | Starts searching for nearby iBeacon devices. | |
plus.ibeacon.stopBeaconDiscovery | Stops searching for nearby iBeacon devices. | |
plus.ibeacon.getBeacons | Obtains all discovered iBeacon devices. | |
plus.ibeacon.onBeaconUpdate | Listens to iBeacon device update events. | |
plus.ibeacon.onBeaconServiceChange | Listens to iBeacon service status change events. |
Biometric authentication
API | Description | References |
uni.startSoterAuthentication | Starts SOTER biometric authentication. | |
uni.checkIsSupportSoterAuthentication | Obtains the natively supported SOTER biometric authentication method. | |
uni.checkIsSoterEnrolledInDevice | Checks whether biometric information such as fingerprints is enrolled in a device. |
Fingerprint
API | Description | References |
plus.fingerprint.isSupport | Determines whether the current device supports fingerprint recognition. | |
plus.fingerprint.isKeyguardSecure | Determines whether passcode lock screen is set for the current device. | |
plus.fingerprint.isEnrolledFingerprints | Determines whether fingerprints are enrolled in the current device. | |
plus.fingerprint.authenticate | Enables fingerprint authentication. | |
plus.fingerprint.cancel | Disables fingerprint authentication. |
OAuth
API | Description | References |
plus.oauth.getServices | Obtains the list of logon authentication services. |
Payment
API | Description | References |
plus.payment.getChannels | Obtains payment channels. | |
plus.payment.request | Initiates a payment request. |
Storage
API | Description | References |
plus.storage.clear | Synchronously clears stored data. | |
plus.storage.clearAsync | Asynchronously clears stored data. | |
plus.storage.getAllKeys | Synchronously obtains all keys. | |
plus.storage.getAllKeysAsync | Asynchronously obtains all keys. | |
plus.storage.getLength | Obtains the length of stored data. | |
plus.storage.getItem | Synchronously obtains stored key-value pairs. | |
plus.storage.getItemAsync | Asynchronously obtains stored key-value pairs. | |
plus.storage.key | Retrieves the key at the specified index in a key-value pair. | |
plus.storage.setItem | Synchronously stores key-value pairs. | |
plus.storage.setItemAsync | Asynchronously stores key-value pairs. | |
plus.storage.removeItem | Synchronously removes key-value pairs. | |
plus.storage.removeItemAsync | Asynchronously removes key-value pairs. |
Keyboard/Key
API | Description | References |
uni.hideKeyboard | Hides the soft keyboard. | |
uni.onKeyboardHeightChange | Listens to keyboard height changes. | |
uni.offKeyboardHeightChange | Cancels listening to keyboard height changes. | |
uni.getSelectedTextRange | Obtains the cursor position of the input box after focus is set on the input and textarea fields. | |
plus.key.hideSoftKeybord | Hides the soft keyboard. | |
plus.key.setAssistantType | Sets the auxiliary input type. | |
plus.key.showSoftKeybord | Shows the soft keyboard. | |
plus.key.addEventListener | Adds a key-press event listener. | |
plus.key.setVolumeButtonEnabled | Sets whether the volume control keys take effect. | |
plus.key.removeEventListener | Removes a key-press event listener. |
UI
Interactive feedback
API | Description | References |
uni.showToast | Shows a toast. | |
uni.hideToast | Hides a toast. | |
uni.showLoading | Shows a loading pop-up. You must call uni.hideLoading to close the pop-up. | |
uni.hideLoading | Hides a loading pop-up. | |
uni.showModal | Shows a modal pop-up window. The window can contain only one OK button, or both the OK and Cancel buttons. It is similar to an API that integrates both the alerting and confirmation functions in HTML. | |
uni.showActionSheet | Shows an action sheet that slides up from the bottom of the screen. | |
plus.nativeUI.actionSheet | Shows an action sheet. | |
plus.nativeUI.alert | Shows an alert dialog box. | |
plus.nativeUI.confirm | Shows a confirmation dialog box. | |
plus.nativeUI.closePreviewImage | Closes an image preview window. | |
plus.nativeUI.closeWaiting | Closes a waiting dialog box. | |
plus.nativeUI.closeToast | Closes a toast. | |
plus.nativeUI.previewImage | Previews an image. | |
plus.nativeUI.showWaiting | Shows a waiting dialog box. | |
plus.nativeUI.pickDate | Shows a date selection dialog box. | |
plus.nativeUI.pickTime | Shows a time selection dialog box. | |
plus.nativeUI.prompt | Shows a prompt dialog box. | |
plus.nativeUI.toast | Shows a toast. | |
plus.nativeUI.setUIStyle | Sets the native UI style. |
Navigation bar
API | Description | References |
uni.setNavigationBarTitle | Dynamically sets the title of the current page. | |
uni.setNavigationBarColor | Sets the color of the navigation bar on the page. Note If the color needs to be set right after the page is loaded, it can be done in the onReady function to avoid being overwritten by changes within the frame. |
TabBar
API | Description | References |
uni.setTabBarItem | Dynamically configures a specific item on a TabBar. | |
uni.setTabBarStyle | Dynamically configures the style of a TabBar. | |
uni.hideTabBar | Hides a TabBar. | |
uni.showTabBar | Shows a TabBar. | |
uni.setTabBarBadge | Adds text to the upper-right corner of a specific item on a TabBar. | |
uni.removeTabBarBadge | Removes the text in the upper-right corner of a specific item on a TabBar. | |
uni.showTabBarRedDot | Shows the red dot in the upper-right corner of a specific item on a TabBar. | |
uni.hideTabBarRedDot | Hides the red dot in the upper-right corner of a specific item on a TabBar. | |
uni.onTabBarMidButtonTap | Listens to the middle button tap events. |
Animation
API | Description | References |
uni.createAnimation | Creates an animation instance. Call instance methods to describe the animation. Then, use the export method to export the animation data, and pass the data to the animation property of the component. |
Scroll
API | Description | References |
uni.pageScrollTo | Scrolls the page to a specific position. |
Window
API | Description | References |
uni.onWindowResize | Listens to window size change events. | |
uni.offWindowResize | Cancels listening to window size change events. |
Font
API | Description | References |
uni.loadFontFace | Dynamically loads network fonts. The file URL must be a download URL. | |
uni.upx2px | Converts rpx to px. |
Pull-to-refresh
API | Description | References |
uni.startPullDownRefresh | Enables pull-to-refresh. Calling this method produces the same result as when a user manually pulls to refresh. | |
uni.stopPullDownRefresh | Disables pull-to-refresh for the current page. |
Node information
API | Description | References |
uni.createSelectorQuery | Returns a SelectorQuery object instance. On this instance, methods such as select can be used to select nodes and methods such as boundingClientRect can be used to select information to be queried. |
Node layout intersection status
API | Description | References |
uni.createIntersectionObserver | Creates and returns an IntersectionObserver object instance. |
Media query
API | Description | References |
uni.createMediaQueryObserver | Creates and returns a MediaQueryObserver object instance. |
Language
API | Description | References |
uni.getLocale | Obtains the current language of the app. | |
uni.setLocale | Sets the language of the app. | |
uni.onLocaleChange | Listens to app language switching events. |
File
API | Description | References |
uni.saveFile | Saves a file to a local path. | |
uni.getSavedFileList | Obtains the list of locally saved files. | |
uni.getSavedFileInfo | Obtains information about a local file. This API can only be used to obtain information about locally saved files. | |
uni.removeSavedFile | Deletes locally stored files. | |
uni.getFileInfo | Obtains information about a file. | |
uni.openDocument | Opens a document in a new page. Only documents in the following formats are supported: doc, xls, ppt, pdf, docx, xlsx, and pptx. | |
plus.io.requestFileSystem | Requests a local file system object. | |
plus.io.resolveLocalFileSystemURL | Obtains a directory object or a file object by using URL parameters. | |
plus.io.convertLocalFileSystemURL | Converts a local URL to an absolute URL. | |
plus.io.convertAbsoluteFileSystem | Converts an absolute URL to a local URL. | |
plus.io.getAudioInfo | Obtains audio information. | |
plus.io.getFileInfo | Obtains file information. | |
plus.io.getImageInfo | Obtains image information. | |
plus.io.getVideoInfo | Obtains video information. |
Download
API | Description | References |
plus.downloader.createDownload | Creates a download task. | |
plus.downloader.enumerate | Enumerates download tasks. | |
plus.downloader.clear | Clears download tasks. | |
plus.downloader.startAll | Starts all download tasks. |
Upload
API | Description | References |
plus.uploader.createUpload | Creates an upload task. | |
plus.uploader.enumerate | Enumerates upload tasks. | |
plus.uploader.clear | Clears upload tasks. | |
plus.uploader.startAll | Starts all upload tasks. |
Compression
API | Description | References |
plus.zip.compress | Compresses a file into a ZIP file. | |
plus.zip.decompress | Decompresses a ZIP file. | |
plus.zip.compressImage | Compresses an image. | |
plus.zip.compressVideo | Compresses a video. |
Drawing
API | Description | References |
uni.createCanvasContext | Creates a drawing context for the specified canvas. In a custom component, the "this" custom component instance is passed as the second parameter to manage the <canvas> component in the component. | |
uni.canvasToTempFilePath | Exports the content of the specified area of the current canvas to generate an image of the specified size, and returns the file path. In a custom component, the custom component instance is passed as the second parameter to manage the <canvas> component in the component. | |
uni.canvasPutImageData | Draws pixel data to the canvas. In a custom component, the "this" custom component instance is passed as the second parameter to manage the <canvas> component in the component. | |
uni.canvasGetImageData | Obtains the implied pixel data for the canvas area. In a custom component, the "this" custom component instance is passed as the second parameter to manage the <canvas> component in the component. |
Database
API | Description | References |
plus.sqlite.openDatabase | Opens a database. | |
plus.sqlite.isOpenDatabase | Determines whether a database is open. | |
plus.sqlite.closeDatabase | Closes a database. | |
plus.sqlite.transaction | Executes a transaction. | |
plus.sqlite.executeSql | Executes SQL statements that are used to perform operations such as adding, removing, and modifying data. | |
plus.sqlite.selectSql | Executes SQL statements for querying data. |
WebView
API | Description | References |
plus.webview.all | Obtains all WebViews. | |
plus.webview.close | Closes a WebView. | |
plus.webview.create | Creates a WebView. | |
plus.webview.currentWebview | Obtains the WebView of the current page. | |
plus.webview.getDisplayWebview | Obtains all WebViews that are visible on the screen. | |
plus.webview.getWebviewById | Finds a WebView by its ID. | |
plus.webview.getLaunchWebview | Obtains the first launch WebView of the app. | |
plus.webview.getSecondWebview | Obtains the second launch WebView of the app. | |
plus.webview.getTopWebview | Obtains the WebView at the top of the view hierarchy of the app. | |
plus.webview.hide | Hides a WebView. | |
plus.webview.open | Creates and opens a WebView. | |
plus.webview.prefetchURL | Prefetches a URL. | |
plus.webview.prefetchURLs | Prefetches URLs. | |
plus.webview.show | Shows a WebView. | |
plus.webview.startAnimation | Starts WebView animations. | |
plus.webview.defaultHardwareAccelerated | Checks whether hardware acceleration is enabled for a WebView by default. |
Third-party service
Service provider acquisition
API | Description | References |
uni.getProvider | Obtains a service provider. |
Logon
API | Description | References |
uni.login | A client API that encapsulates various common logon methods from various platforms, including mobile number-based logon, three-party logon (WeChat, Weibo, QQ, Apple, Google, and Facebook), and built-in logon of various miniapps. | |
uni.getUserInfo | Obtains user information. | |
uni.preLogin | Establishes a pre-logon connection to the app. This API is used for mobile number-based logon. | |
uni.closeAuthView | Closes the One-click login page. According to the requirements of operators such as China Mobile, China Unicom, and China Telecom, UI pages are required for mobile number-based logon. This API can be used to close such pages. | |
uni.getCheckBoxState | Obtains the status of the check box for One-click login terms. | |
uni.getUniverifyManager | Obtains a globally unique univerifyManager object. |
Speech recognition
API | Description | References |
plus.speech.startRecognize | Starts speech recognition. | |
plus.speech.stopRecognize | Stops speech recognition. | |
plus.speech.addEventListener | Listens to speech recognition events. |
Sharing
API | Description | References |
uni.share | The uni-app engine has encapsulated the sharing SDKs of WeChat, QQ, and Weibo. You can directly call relevant functions. | |
uni.shareWithSystem | Calls the system sharing component to send messages to be shared. You do not need to configure the sharing SDK. | |
plus.share.sendWithSystem | Calls the system sharing component to send messages to be shared. | |
plus.share.getServices | Obtains sharing services. |
Payment
API | Description | References |
uni.requestPayment | Initiates a payment request. |
Push
API | Description | References |
uni.getPushClientId | Obtains the unique ID of the push client. | |
uni.onPushMessage | Listens to message push events. | |
uni.offPushMessage | Cancels listening to message push events. | |
uni.createPushMessage | Creates a local notification bar message. | |
plus.push.addEventListener | Adds a message push event listener. | |
plus.push.clear | Clears all push messages. | |
plus.push.createMessage | Creates a local message. | |
plus.push.getAllMessage | Obtains all push messages. | |
plus.push.getClientInfo | Synchronously obtains information about the push client. | |
plus.push.getClientInfoAsync | Asynchronously obtains information about the push client. | |
plus.push.setAutoNotification | Sets whether to automatically display notification messages in the Message Center. | |
plus.push.remove | Deletes a push message. |
ID verification
API | Description | References |
uni.getFacialRecognitionMetaInfo | Obtains ID verification device information. | |
uni.startFacialRecognitionVerify | Starts ID verification. |
Statistics
API | Description | References |
plus.statistic.eventTrig | Triggers a statistics event. | |
plus.statistic.eventDuration | Collects statistics of a durative event. |