All Products
Search
Document Center

API list

Last Updated: Apr 20, 2021

This document includes all the APIs involved in mPaaS Mini Program. See the corresponding API documents for the specific API details.

UI

Navigation bar

Name Features
my.getTitleColor Get the background color of the navigation bar.
my.hideBackHome Hide the “Back to Homepage” icon on the title bar.
my.hideNavigationBarLoading Hide loading animation on the navigation bar of the current page.
my.showNavigationBarLoading Show loading animation on the navigation bar of the current page.
my.setNavigationBar Set navigation bar style including title, background color, bottom border color, and logo image in the upper-left corner of the navigation bar.

tabBar

Name Features
my.hideTabBar Hide tabBar.
my.hideTabBarRedDot Hide the red dot in the upper-right corner of an item on the tabBar.
my.removeTabBarBadge Remove text in the upper-right corner of an item on the tabBar.
my.setTabBarBadge Add text in the upper-right corner of an item on the tabBar. You can use red dot reminder to set the number of messages.
my.setTabBarItem Set the content of an item on the tabBar dynamically.
my.setTabBarStyle Set the general style of tabBar dynamically, such as font color, tab background color, and label border color.
my.showTabBar Show tabBar.
my.showTabBarRedDot Show the red dot in the upper-right corner of an item on the tabBar.
onTabItemTap You can click a tab to trigger the function and listen to the events of tabBar click.
FAQ regarding tabBar Answers to FAQ regarding tab.

Routes

Name Features
my.switchTab Switch to the specific tabBar page and close all the irrelevant pages.
my.reLaunch Close all the current pages and relaunch to the specific page in the application.
my.redirectTo Close the current page and redirect to the specific page in the application.
my.navigateTo Navigate to the specific page in the application from the current page.
my.navigateBack Close the current page and navigate back to the previous level or multilevel page.
FAQ regarding routes Answers to FAQ regarding routes.

Interaction feedback

Name Features
my.alert Alert box (alert).
my.confirm Confirm box (confirm).
my.prompt You can enter text in the prompting dialogue box.
my.showToast Show a toast. You can set the time that the toast lasts.
my.hideToast Hide toasts.
my.showLoading Show loading prompts.
my.hideLoading Hide loading prompts.
my.showActionSheet Show action sheet.

Pull-down refresh

Name Features
onPullDownRefresh Listen to the pull-down refresh events that are performed by users on this page.
my.stopPullDownRefresh Stop the operations of pull-down refresh on the current page.
my.startPullDownRefresh Start the operations of pull-down refresh.

Contact

Name Features
my.choosePhoneContact Select the phone number of a contact in the directory of the local system.

Choose city

Name Features
my.chooseCity You can call this operation to open the city list.
my.onLocatedComplete You can customize onLocatedComplete function and listen to the callback after the page located. This operation is only for the case when the attribute setLocatedCity in my.chooseCity is true.
my.setLocatedCity You can call this operation to modify the default name of the located city in my.chooseCity.

Choose date

Name Features
my.datePicker Open the date picker list.

Animation

Name Features
my.createAnimation Create animation instances.

Canvas

Name Features
my.createCanvasContext Create canvas drawing context.

Keypad

Name Features
my.hideKeyboard Hide keypad.

Scroll

Name Features
my.pageScrollTo Scroll to the target location on the page.

Node query

Name Features
my.createSelectorQuery Get a node query object SelectorQuery.

Option selector

Name Features
my.optionsSelect A component similar to the native Safari select but with more powerful features, which you can use to replace select or level 2 data.
Note: The component does not support interactions among level 2 data.

Multilevel select

Name Features
my.multiLevelSelect Business scenarios for relevant multilevel data selection such as the information selection of province, city, and region.

Set background window

Name Features
my.setBackgroundColor Set the background color of the settings window dynamically.
my.setBackgroundTextStyle Set the font of the pull-down background, and the style of loading graphic dynamically.

Set page pulldown

Name Features
my.setCanPullDown Set if the page supports pull down operations. By default, the page in the mini program supports pull down operations.

Set optionMenu

Name Features
my.setOptionMenu Configure extra icons on the optionMenu navigation bar, and then click to trigger onOptionMenuClick.

Multimedia

Image

Name Features
my.chooseImage Take photos or select images from your mobile phone album.
my.previewImage Preview images.
my.saveImage Save online images to your mobile phone album.
my.compressImage Compress images.
my.getImageInfo Get image information.

Storage

Name Features
my.setStorage The operation to save data in the specific key of the local storage will overwrite the corresponding data to this key.
my.setStorageSync Synchronize data in the specific key of the local storage.
my.getStorage Get data from the storage asynchronously.
my.getStorageSync Get data from the storage synchronously.
my.removeStorage Remove asynchronous operations for data storage.
my.removeStorageSync Remove synchronous operations for data storage.
my.clearStorage Clear asynchronous operations for local data storage.
my.clearStorageSync Clear synchronous operations for local data storage.
my.getStorageInfo Get relevant information for the current storage asynchronously.
my.getStorageInfoSync Get relevant information for the current storage synchronously.

File

Name Features
my.saveFile Save file to local system. The maximum local file size is 10 MB.
my.getFileInfo Get file information.
my.getSavedFileInfo Get the saved file information.
my.getSavedFileList Get all the save files.
my.removeSavedFile Remove a saved file.

Location

Name Features
my.chooseLocation Use the built-in map to select geographical location.
my.getLocation Get current location information about the user.
my.openLocation Use the built-in map of mPaaS mini program to view your location.

Network

Name Features
my.request Network request of the mini program.
my.uploadFile Upload local resource to the developer server.
my.downloadFile Download files to the local system.
my.connectSocket Create a WebSocket connection.
my.onSocketOpen Listen to the events of WebSocket connection open.
my.offSocketOpen Stop listening to the events of WebSocket connection off.
my.onSocketError Listen to WebSocket errors.
my.offSocketError Stop listening to WebSocket errors.
my.sendSocketMessage Send data through WebSocket connection.
my.onSocketMessage Listen to the message events on the server received by WebSocket.
my.offSocketMessage Stop listening to message events on the server received by WebSocket.
my.closeSocket Close WebSocket connection.
my.onSocketClose Listen to close WebSocket connection.
my.offSocketClose Stop listening to close WebSocket connection.

Device

canIUse

Name Features
my.canIUse Determine if the current version supports API operations, input parameters or output values, components, and attributes of the current mini program.

Get base library version number

Name Features
my.SDKVersion Get the version number of the base library.
For reference only, do not rely on this value for code logic.

System information

Name Features
my.getSystemInfo Get mobile phone system information.
my.getSystemInfoSync Get the synchronous operation for mobile phone system information.

Network status

Name Features
my.getNetworkType Get current network status.
my.onNetworkStatusChange Start listening to network status changes.
my.offNetworkStatusChange Stop listening to network status changes.

Clipboard

Name Features
my.getClipboard Get clipboard data.
my.setClipboard Set clipboard data.

Shake

Name Features
my.watchShake Use shake feature. Every time you call the API, the callback will be triggered after you shake the mobile phone. If you need to listen again, you have to recall this API.

Vibrate

Name Features
my.vibrate Use vibrate feature.
my.vibrateLong Long vibration lasts for 400 ms.
my.vibrateShort Short vibration lasts for 40 ms.

Accelerometer

Name Features
my.onAccelerometerChange Listen to accelerometer data.
my.offAccelerometerChange Stop listening to accelerometer data.

Gyroscope

Name Features
my.onGyroscopeChange Listen to the events of gyroscope data change.
my.offGyroscopeChange Stop listening to gyroscope data.

Compass

Name Features
my.onCompassChange Listen to compass data.
my.offCompassChange Stop listening to compass data.

Make phone calls

Name Features
my.makePhoneCall Make phone calls.

Events of user capture screen

Name Features
my.onUserCaptureScreen Listen to the events of active screen capture initiated by the user.
my.offUserCaptureScreen Stop listening to the events of screen capture.

Screen brightness

Name Features
my.setKeepScreenOn Set whether to keep the screen on.
my.getScreenBrightness Get screen brightness.
my.setScreenBrightness Set screen brightness.

Add phone contact

Name Features
my.addPhoneContact You can add the list to the directory in the mobile phone system by Create New Contact or Add to Existing Contact.

Scan

Name Features
my.scan Use scan feature.

Bluetooth

Name Features
my.openBluetoothAdapter Initialize Bluetooth module of the mini program.
my.closeBluetoothAdapter Turn off the local Bluetooth module.
my.getBluetoothAdapterState Get the status of the local Bluetooth module.
my.startBluetoothDevicesDiscovery Start searching for nearby Bluetooth devices.
my.stopBluetoothDevicesDiscovery Stop searching for nearby Bluetooth devices.
my.getBluetoothDevices Get all discovered Bluetooth devices, including the Bluetooth device that is already connected.
my.getConnectedBluetoothDevices Get connected devices.
my.connectBLEDevice Connect to the Bluetooth Low Energy (BLE) device.
my.disconnectBLEDevice Disconnect from the BLE device.
my.writeBLECharacteristicValue Write data into the characteristic value of the BLE device.
my.readBLECharacteristicValue Read the data from the characteristic value of the BLE device.
my.notifyBLECharacteristicValueChange Enable the notify feature for the characteristic value change of the BLE device.
my.getBLEDeviceServices Get all the services of Bluetooth devices.
my.getBLEDeviceCharacteristics Get all the characteristic values of Bluetooth devices.
my.onBluetoothDeviceFound This event is triggered when a new Bluetooth device is found.
my.offBluetoothDeviceFound Stop listening to the events of searches for new Bluetooth devices.
my.onBLECharacteristicValueChange Listen to the events of characteristic value changes of the BLE device.
my.offBLECharacteristicValueChange Stop listening to the events of characteristic value changes of the BLE device.
my.onBLEConnectionStateChanged Listen to the events of BLE connection errors, such as device loss and abnormal disconnection.
my.offBLEConnectionStateChanged Stop listening to the events of connection status changes of the BLE device.
my.onBluetoothAdapterStateChange Listen to the events of local Bluetooth status changes.
my.offBluetoothAdapterStateChange Stop listening to the events of local Bluetooth status changes.
Error code List for the error code of Bluetooth API.

Data security

Name Features
my.rsa Asymmetric encryption.

Share

Name Features
onShareAppMessage Customize onShareAppMessage function on the page to set the information for sharing on this page.
my.hideShareMenu Hide Share button.

Current running version

Name Features
my.getRunScene Get the running version of the current mini program.

Custom analysis

Name Features
my.reportAnalytics Customize the report operation of data analysis.

Mini program redirection

Name Features
my.navigateToMiniProgram Navigate to other mini programs.
my.navigateBackMiniProgram You can navigate back to the previous mini program only when another mini program is navigated to the active mini program.

webview component control

Name Features
my.createWebViewContext Create and return webViewContext object.
webViewContext You can bind WebViewContext with a web-view component and implement some features through webviewId.