JSAPI Reference
Basic
API Name | Function Description |
my.canIUse | Judge whether the current Mini Program API, incoming parameter or return value, component, attribute, etc. are supported in the current version. |
my.SDKVersion | Get the SDK version. |
my.getAppIdSync | Obtain the Mini Program App ID synchronously. |
my.getRunScene | Obtain the running version of the current Mini Program. |
UI
NavigationBar
API Name | Function Description |
my.hideBackHome | Hide back to home button. |
my.hideNavigationBarLoading | Hide navigation bar loading. |
my.setNavigationBar | Set the navigation bar text and style. |
my.showNavigationBarLoading | Show navigation bar loading. |
TabBar
API Name | Function Description |
my.hideTabBar | Hide the tabBar. |
my.setTabBarStyle | Set the style of tabBar. |
TabBar FAQ | The FAQ of TabBar. |
Route
API Name | Function Description |
my.switchTab | Jump to the specified tabBar page and close all other pages that are not tabBar. |
my.navigateTo | Maintain the current page and jump to the specified page within the application. Use my.navigateBack to return to the original page. |
my.reLaunch | Close all current pages and jump to the specified page within the application. |
my.navigateBack | Close the current page and return to the previous one or more pages. |
my.redirectTo | Close the current page and jump to the specified page within the application. |
FeedBack
API Name | Function Description |
my.alert | Alert box. |
my.confirm | Confirm box. |
my.prompt | Prompt box. |
my.showToast | Show a weak hint, which disappears in the specified seconds. |
my.hideToast | Hide the weak hint. |
my.showLoading | Show the loading hint. |
my.hideLoading | Hide the loading hint. |
my.showActionSheet | Display an operation menu. |
Pulldown
API Name | Function Description |
onPullDownRefresh | On the Page, customize the onPullDownRefresh function to listen to the pull-to-refresh event of user. |
my.stopPullDownRefresh | Stop the pull-to-refresh for the current page. |
my.startPullDownRefresh | Start the pull-to-refresh function. |
Contact
API Name | Function Description |
my.choosePhoneContact | Choose contact from system contact. |
Choose Data
API Name | Function Description |
my.datePicker | Open a date selection list. |
Animation
API Name | Function Description |
my.createAnimation | Create an instance of animation. |
Canvas
API Name | Function Description |
my.createCanvasContext | Create the context of the canvas. |
Keyboard
API Name | Function Description |
my.hideKeyboard | Hide keyboard. |
Scroll
API Name | Function Description |
my.pageScrollTo | Scroll to the destination location of the page. |
SelectorQuery
API Name | Function Description |
my.createSelectorQuery | Create an instance of SelectorQuery. |
Multiple Level Select
API Name | Function Description |
my.multiLevelSelect | Multiple level selector, used for associated select with multiple levels. |
Set Background
API Name | Function Description |
my.setBackgroundColor | Set background color. |
Set Page Pulldown
API Name | Function Description |
my.setCanPullDown | Set whether page can support pulldown. |
Media
Image
API Name | Function Description |
my.chooseImage | Choose image from camera or album of cellphone. |
my.previewImage | Preview image. |
my.saveImage | Save the online images to cellphone album. |
my.getImageInfo | Get the information of the image. |
Storage
API Name | Function Description |
my.setStorage | Store the data in the specified key in the local cache, which overlaps the original data corresponding to the key. |
my.setStorageSync | Store synchronously the data in the specified key in the local cache. |
my.getStorage | Get cached data. |
my.getStorageSync | Get cached data synchronously. |
my.removeStorage | Remove cached data. |
my.removeStorageSync | Remove cached data synchronously. |
my.clearStorage | Clear local data cache. |
my.clearStorageSync | Clear local data cache synchronously. |
File
API Name | Function Description |
my.saveFile | Save file to the device. |
my.getFileInfo | Get the information of the file. |
my.getSavedFileInfo | Get the information of the saved file. |
my.getSavedFileList | Get the information of all the saved file. |
my.removeSavedFile | Remove the saved file. |
Location
API Name | Function Description |
my.getLocation | get the current geographical location of the user. |
Network
API Name | Function Description |
my.request | Network request. |
my.uploadFile | Upload the local resource to the developer server. |
my.downloadFile | Download file resource to local location. |
my.connectSocket | Create a WebSocket connection. |
my.onSocketOpen | Listen to the event of enabling the WebSocket connection. |
my.offSocketOpen | Unlisten to the event of enabling the WebSocket connection. |
my.onSocketError | Listen to WebSocket error events. |
my.offSocketError | Unlisten to WebSocket error events. |
my.sendSocketMessage | Send data over WebSocket connection. |
my.onSocketMessage | Listen to the event of receiving server messages by WebSocket. |
my.offSocketMessage | Unlisten to the event of receiving server messages by WebSocket. |
my.closeSocket | Close the WebSocket connection. |
my.onSocketClose | Listen to the event of closing the WebSocket connection. |
my.offSocketClose | Unlisten to the event of closing the WebSocket connection. |
Device
System Information
API Name | Function Description |
my.getSystemInfo | Get system information. |
Network Status
API Name | Function Description |
my.getNetworkType | Get the current network status. |
Clipboard
API Name | Function Description |
my.getClipboard | Get the clipboard data. |
my.setClipboard | Set the clipboard data. |
Watch Shake
API Name | Function Description |
my.watchShake | The watchshake function. |
Accelerometer
API Name | Function Description |
my.onAccelerometerChange | Listen to the acceleration data event. |
my.offAccelerometerChange | Unlisten to the acceleration data event. |
Compass
API Name | Function Description |
my.onCompassChange | Listen to the compass data change event. |
my.offCompassChange | Unlisten to the compass data change event. |
Vibrate
API Name | Function Description |
my.vibrate | Invoke the vibrate ability of device. |
Make Phone Call
API Name | Function Description |
my.makePhoneCall | Make a phone call. |
Get Server Time
API Name | Function Description |
my.getServerTime | Get the server time. |
Capture Screen
API Name | Function Description |
my.onUserCaptureScreen | Listen to the capture screen event by users. |
my.offUserCaptureScreen | Cancel the listen to the capture screen event by users. |
Screen Brightness
API Name | Function Description |
my.setKeepScreenOn | Set whether screen keeps awake. |
my.getScreenBrightness | Get the screen brightness. |
my.setScreenBrightness | Set the screen brightness. |
Setting
API Name | Function Description |
my.openSetting | Open the Mini Program settings page. |
my.getSetting | Obtain the user's current settings. |
Add Phone Contact
API Name | Function Description |
my.addPhoneContact | Add contact to phone contact. |
Permission Guide
API Name | Function Description |
my.showAuthGuide | Guide user to grant the authorization when the permission needed. |
Scan
API Name | Function Description |
my.scan | Call the scanning QR code function. |
Memory Warning
API Name | Function Description |
my.onMemoryWarning | Listen to the insufficient memory alarm event. |
my.offMemoryWarning | Unlisten to the insufficient memory alarm event. |
Battery Information
API Name | Function Description |
my.getBatteryInfo | Obtain the battery level and the charging state of the current device asynchronously. |
my.getBatteryInfoSync | Obtain the battery level and the charging state of the current device synchronously. |
Bluetooth
API Name | Function Description |
Bluetooth API Error Code Table | List the normal error code and relative solutions. |
Bluetooth API FAQ | FAQ about using Bluetooth API. |
BLE
API Name | Function Description |
my.connectBLEDevice | Connect to low energy bluetooth devices. |
my.disconnectBLEDevice | Disconnect to low energy bluetooth devices. |
my.getBLEDeviceCharacteristics | Get the characteristics of low energy bluetooth devices. |
my.getBLEDeviceServices | Get all the low energy bluetooth devices that are discovered, including the connected devices. |
my.notifyBLECharacteristicValueChange | Enable the function to notify changes to the characteristic value. |
my.offBLECharacteristicValueChange | Disable the function to notify changes to the characteristic value. |
my.offBLEConnectionStateChanged | Disable the the event listener for the connection status. |
my.onBLECharacteristicValueChange | Enable the event listener for changes to the characteristic value. |
my.onBLEConnectionStateChanged | Enable the the event listener for changes to the connection status , such as device lost and device disconnected. |
my.readBLECharacteristicValue | Read the characteristic value. |
my.writeBLECharacteristicValue | Write data to the characteristic value. |
Bluetooth
API Name | Function Description |
my.openBluetoothAdapter | Use this API to initialize the Bluetooth module in the mini program. |
my.closeBluetoothAdapter | Use this API to close the Bluetooth module in the mini program. |
my.getBluetoothAdapterState | Use this API to check the Bluetooth adapter status in the mini program. |
my.startBluetoothDevicesDiscovery | Use this API to start discovering bluetooth devices. |
my.stopBluetoothDevicesDiscovery | Use this API to stop discovering bluetooth devices. |
my.getBluetoothDevices | Use this API to get all the bluetooth devices that are discovered, including those that are connected to the current device. |
my.getConnectedBluetoothDevices | Use this API to get the bluetooth devices that are connected. |
my.onBluetoothDeviceFound | Use this API when a new Bluetooth device is found. |
my.offBluetoothDeviceFound | Use this API to remove the bluetooth devices that are found. |
my.onBluetoothAdapterStateChange | Use this API to monitor the bluetooth adapter state changes. |
my.offBluetoothAdapterStateChange | Use this API to remove the bluetooth adapter with a state change. |
web-view
API Name | Function Description |
my.createWebViewContext | By creating webViewContext , Mini Program can send message to web-view . This API will create a webViewContext instance |
Site Info
API Name | Function Description |
my.getSiteInfo | Get the site information. |
Open Capabilities
API Name | Function Description |
my.getAuthCode | Get auth code. |
my.getOpenUserInfo | Get basic information about user. |
my.tradePay | Start to pay. |
my.navigateToMiniProgram | Jump to other Mini Program. |
my.navigateBackMiniProgram | Return to the previous Mini Program, only when another Mini Program jumps to the current Mini Program. |
my.signContract | Sign the withholding contract. |
my.getPhoneNumber | Get the phone number. |
Experience Mini Program
Developers can use the Android Demo App to scan the QR code shown in the API documents.