All Products
Search
Document Center

SuperApp:uni-app JavaScript APIs

Last Updated:Oct 31, 2024

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.

Important

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.

link

uni.arrayBufferToBase64

Converts an ArrayBuffer object to a Base64 string.

link

uni.getLaunchOptionsSync

Obtains the parameters for cold startup.

link

uni.getEnterOptionsSync

Obtains the parameters for hot startup.

link

uni.addInterceptor

Adds an interceptor.

link

uni.removeInterceptor

Removes an interceptor.

link

uni.canIUse

Determines whether the APIs, callbacks, parameters, and components of the app are available in the current version.

link

Network

Request initiation

API

Description

References

uni.request

Initiates a network request.

link

Upload/Download

API

Description

References

uni.uploadFile

Uploads local resources to your server. The client initiates an HTTP POST request with content-type set to multipart/form-data.

link

uni.downloadFile

Downloads a file to your local device. The client directly initiates an HTTP GET request. The local temporary path to the file is returned.

WebSocket

API

Description

References

uni.connectSocket

Creates a WebSocket connection.

link

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.

link

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.

link

uni.redirectTo

Closes the current page and redirects to the specified page in the app.

link

uni.reLaunch

uni.reLaunch

Closes all pages and redirects to the specified page in the app.

link

uni.switchTab

uni.switchTab

Redirects to the specified TabBar page and closes all other non-TabBar pages.

link

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.

link

uni.preloadPage

uni.preloadPage

Preloads pages. Page pre-loading is a performance optimization technology. The preloaded pages can be opened faster.

link

EventChannel

API

Description

References

EventChannel.emit

Triggers an event.

link

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.

link

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.

link

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.

link

uni.setStorageSync

Stores data in the specified key in the local cache. This synchronous operation will overwrite the original content of the key.

link

uni.getStorage

Asynchronously obtains the content of the specified key from the local cache.

link

uni.getStorageSync

Synchronously obtains the content of the specified key from the local cache.

link

uni.getStorageInfo

Asynchronously obtains information about the current storage.

link

uni.getStorageInfoSync

Synchronously obtains information about the current storage.

link

uni.removeStorage

Asynchronously removes the specified key from the local cache.

link

uni.removeStorageSync

Synchronously removes the specified key from the local cache.

link

uni.clearStorage

Asynchronously clears the locally cached data.

link

uni.clearStorageSync

Synchronously clears the locally cached data.

link

Location

Location acquisition

API

Description

References

uni.getLocation

Obtains the current geographic location and speed.

link

uni.chooseLocation

Opens a map and selects a location.

plus.geolocation.getCurrentPosition

Obtains the current location of the device.

Geolocation

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.

link

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.

Geolocation

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.

link

plus.maps.openSysMap

Calls a third-party app for navigation.

Maps

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.

link

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.

Gallery

plus.gallery.save

Saves a file to the local album.

Camera

API

Description

References

plus.camera.getCamera

Obtains a camera object.

Camera

Recording

API

Description

References

ni.getRecorderManager

Obtains a globally unique recorderManager object.

link

plus.audio.getRecorder

Obtains the recorder of the current device.

Audio

plus.audio.createPlayer

Creates an audio player.

Background audio

API

Description

References

uni.getBackgroundAudioManager

Obtains a globally unique backgroundAudioManager object.

link

Audio component control

API

Description

References

uni.createInnerAudioContext

Creates and returns an innerAudioContext object.

link

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.

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.

Video

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.

link

Device

System

API

Description

References

uni.getSystemInfo

Asynchronously obtains system information.

link

uni.getSystemInfoSync

Synchronously obtains system information.

uni.getDeviceInfo

Obtains the basic information about a device.

link

link

uni.getWindowInfo

Obtains window information.

link

uni.getSystemSetting

Obtains device settings.

link

uni.openAppAuthorizeSetting

Redirects to the app authorization management page.

link

plus.device.beep

Makes a device to beep.

Device

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.

Navigator

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.

Orientation

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.

Proximity

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.

runtime

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.

link

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.

link

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.

link

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.

Accelerometer

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.

link

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.

link

plus.device.dial

Makes a phone call.

Device

Code scanning

API

Description

References

uni.scanCode

Scans a code and returns the result.

link

plus.barcode.scan

Scans the barcode in an image.

Barcode

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.

link

uni.getClipboardData

Obtains content from the system clipboard.

Screen brightness

API

Description

References

uni.setScreenBrightness

Sets the screen brightness.

link

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.

link

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.

link

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.

link

plus.contacts.getAddressBook

Obtains the address book.

Contacts

SMS or email

API

Description

References

plus.messaging.createMessage

Creates a message object.

Messaging

plus.messaging.sendMessage

Sends a message.

Bluetooth

API

Description

References

uni.openBluetoothAdapter

Initializes the Bluetooth module.

link

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.

Bluetooth

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.

link

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.

Bluetooth

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.

link

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.

iBeacon

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.

link

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.

Fingerprint

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.

OAuth

Payment

API

Description

References

plus.payment.getChannels

Obtains payment channels.

Payment

plus.payment.request

Initiates a payment request.

Storage

API

Description

References

plus.storage.clear

Synchronously clears stored data.

Storage

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.

link

uni.onKeyboardHeightChange

Listens to keyboard height changes.

link

uni.offKeyboardHeightChange

Cancels listening to keyboard height changes.

link

uni.getSelectedTextRange

Obtains the cursor position of the input box after focus is set on the input and textarea fields.

link

plus.key.hideSoftKeybord

Hides the soft keyboard.

Key

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.

link

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.

NativeUI

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.

link

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.

link

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.

link

Scroll

API

Description

References

uni.pageScrollTo

Scrolls the page to a specific position.

link

Window

API

Description

References

uni.onWindowResize

Listens to window size change events.

link

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.

link

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.

link

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.

link

Node layout intersection status

API

Description

References

uni.createIntersectionObserver

Creates and returns an IntersectionObserver object instance.

link

Media query

API

Description

References

uni.createMediaQueryObserver

Creates and returns a MediaQueryObserver object instance.

link

Language

API

Description

References

uni.getLocale

Obtains the current language of the app.

link

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.

link

uni.getSavedFileList

Obtains the list of locally saved files.

link

uni.getSavedFileInfo

Obtains information about a local file. This API can only be used to obtain information about locally saved files.

link

uni.removeSavedFile

Deletes locally stored files.

link

uni.getFileInfo

Obtains information about a file.

link

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.

link

plus.io.requestFileSystem

Requests a local file system object.

IO

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.

Downloader

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.

Uploader

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.

Zip

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.

link

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.

link

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.

link

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.

link

Database

API

Description

References

plus.sqlite.openDatabase

Opens a database.

SQLite

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.

Webview

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.

link

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.

link

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.

Speech

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.

link

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.

Share

plus.share.getServices

Obtains sharing services.

Payment

API

Description

References

uni.requestPayment

Initiates a payment request.

link

Push

API

Description

References

uni.getPushClientId

Obtains the unique ID of the push client.

link

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.

Push

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.

link

uni.startFacialRecognitionVerify

Starts ID verification.

Statistics

API

Description

References

plus.statistic.eventTrig

Triggers a statistics event.

Statistic

plus.statistic.eventDuration

Collects statistics of a durative event.