JSAPI Reference

Basic

API NameFunction Description
my.canIUseJudge whether the current Mini Program API, incoming parameter or return value, component, attribute, etc. are supported in the current version.
my.SDKVersionGet the SDK version.
my.getAppIdSyncObtain the Mini Program App ID synchronously.
my.getRunSceneObtain the running version of the current Mini Program.

UI

API NameFunction Description
my.hideBackHomeHide back to home button.
my.hideNavigationBarLoadingHide navigation bar loading.
my.setNavigationBarSet the navigation bar text and style.
my.showNavigationBarLoadingShow navigation bar loading.

TabBar

API NameFunction Description
my.hideTabBarHide the tabBar.
my.setTabBarStyleSet the style of tabBar.
TabBar FAQThe FAQ of TabBar.

Route

API NameFunction Description
my.switchTabJump to the specified tabBar page and close all other pages that are not tabBar.
my.navigateToMaintain the current page and jump to the specified page within the application. Use my.navigateBackto return to the original page.
my.reLaunchClose all current pages and jump to the specified page within the application.
my.navigateBackClose the current page and return to the previous one or more pages.
my.redirectToClose the current page and jump to the specified page within the application.

FeedBack

API NameFunction Description
my.alertAlert box.
my.confirmConfirm box.
my.promptPrompt box.
my.showToastShow a weak hint, which disappears in the specified seconds.
my.hideToastHide the weak hint.
my.showLoadingShow the loading hint.
my.hideLoadingHide the loading hint.
my.showActionSheetDisplay an operation menu.

Pulldown

API NameFunction Description
onPullDownRefreshOn the Page, customize the onPullDownRefresh function to listen to the pull-to-refresh event of user.
my.stopPullDownRefreshStop the pull-to-refresh for the current page.
my.startPullDownRefreshStart the pull-to-refresh function.

Contact

API NameFunction Description
my.choosePhoneContactChoose contact from system contact.

Choose Data

API NameFunction Description
my.datePickerOpen a date selection list.

Animation

API NameFunction Description
my.createAnimationCreate an instance of animation.

Canvas

API NameFunction Description
my.createCanvasContextCreate the context of the canvas.

Keyboard

API NameFunction Description
my.hideKeyboardHide keyboard.

Scroll

API NameFunction Description
my.pageScrollToScroll to the destination location of the page.

SelectorQuery

API NameFunction Description
my.createSelectorQueryCreate an instance of SelectorQuery.

Multiple Level Select

API NameFunction Description
my.multiLevelSelectMultiple level selector, used for associated select with multiple levels.

Set Background

API NameFunction Description
my.setBackgroundColorSet background color.

Set Page Pulldown

API NameFunction Description
my.setCanPullDownSet whether page can support pulldown.

Media

Image

API NameFunction Description
my.chooseImageChoose image from camera or album of cellphone.
my.previewImagePreview image.
my.saveImageSave the online images to cellphone album.
my.getImageInfoGet the information of the image.

Storage

API NameFunction Description
my.setStorageStore the data in the specified key in the local cache, which overlaps the original data corresponding to the key.
my.setStorageSyncStore synchronously the data in the specified key in the local cache.
my.getStorageGet cached data.
my.getStorageSyncGet cached data synchronously.
my.removeStorageRemove cached data.
my.removeStorageSyncRemove cached data synchronously.
my.clearStorageClear local data cache.
my.clearStorageSyncClear local data cache synchronously.

File

API NameFunction Description
my.saveFileSave file to the device.
my.getFileInfoGet the information of the file.
my.getSavedFileInfoGet the information of the saved file.
my.getSavedFileListGet the information of all the saved file.
my.removeSavedFileRemove the saved file.

Location

API NameFunction Description
my.getLocationget the current geographical location of the user.

Network

API NameFunction Description
my.requestNetwork request.
my.uploadFileUpload the local resource to the developer server.
my.downloadFileDownload file resource to local location.
my.connectSocketCreate a WebSocket connection.
my.onSocketOpenListen to the event of enabling the WebSocket connection.
my.offSocketOpenUnlisten to the event of enabling the WebSocket connection.
my.onSocketErrorListen to WebSocket error events.
my.offSocketErrorUnlisten to WebSocket error events.
my.sendSocketMessageSend data over WebSocket connection.
my.onSocketMessageListen to the event of receiving server messages by WebSocket.
my.offSocketMessageUnlisten to the event of receiving server messages by WebSocket.
my.closeSocketClose the WebSocket connection.
my.onSocketCloseListen to the event of closing the WebSocket connection.
my.offSocketCloseUnlisten to the event of closing the WebSocket connection.

Device

System Information

API NameFunction Description
my.getSystemInfoGet system information.

Network Status

API NameFunction Description
my.getNetworkTypeGet the current network status.

Clipboard

API NameFunction Description
my.getClipboardGet the clipboard data.
my.setClipboardSet the clipboard data.

Watch Shake

API NameFunction Description
my.watchShakeThe watchshake function.

Accelerometer

API NameFunction Description
my.onAccelerometerChangeListen to the acceleration data event.
my.offAccelerometerChangeUnlisten to the acceleration data event.

Compass

API NameFunction Description
my.onCompassChangeListen to the compass data change event.
my.offCompassChangeUnlisten to the compass data change event.

Vibrate

API NameFunction Description
my.vibrateInvoke the vibrate ability of device.

Make Phone Call

API NameFunction Description
my.makePhoneCallMake a phone call.

Get Server Time

API NameFunction Description
my.getServerTimeGet the server time.

Capture Screen

API NameFunction Description
my.onUserCaptureScreenListen to the capture screen event by users.
my.offUserCaptureScreenCancel the listen to the capture screen event by users.

Screen Brightness

API NameFunction Description
my.setKeepScreenOnSet whether screen keeps awake.
my.getScreenBrightnessGet the screen brightness.
my.setScreenBrightnessSet the screen brightness.

Setting

API NameFunction Description
my.openSettingOpen the Mini Program settings page.
my.getSettingObtain the user's current settings.

Add Phone Contact

API NameFunction Description
my.addPhoneContactAdd contact to phone contact.

Permission Guide

API NameFunction Description
my.showAuthGuideGuide user to grant the authorization when the permission needed.

Scan

API NameFunction Description
my.scanCall the scanning QR code function.

Memory Warning

API NameFunction Description
my.onMemoryWarningListen to the insufficient memory alarm event.
my.offMemoryWarningUnlisten to the insufficient memory alarm event.

Battery Information

API NameFunction Description
my.getBatteryInfoObtain the battery level and the charging state of the current device asynchronously.
my.getBatteryInfoSyncObtain the battery level and the charging state of the current device synchronously.

Bluetooth

API NameFunction Description
Bluetooth API Error Code TableList the normal error code and relative solutions.
Bluetooth API FAQFAQ about using Bluetooth API.

BLE

API NameFunction Description
my.connectBLEDeviceConnect to low energy bluetooth devices.
my.disconnectBLEDeviceDisconnect to low energy bluetooth devices.
my.getBLEDeviceCharacteristicsGet the characteristics of low energy bluetooth devices.
my.getBLEDeviceServicesGet all the low energy bluetooth devices that are discovered, including the connected devices.
my.notifyBLECharacteristicValueChangeEnable the function to notify changes to the characteristic value.
my.offBLECharacteristicValueChangeDisable the function to notify changes to the characteristic value.
my.offBLEConnectionStateChangedDisable the the event listener for the connection status.
my.onBLECharacteristicValueChangeEnable the event listener for changes to the characteristic value.
my.onBLEConnectionStateChangedEnable the the event listener for changes to the connection status , such as device lost and device disconnected.
my.readBLECharacteristicValueRead the characteristic value.
my.writeBLECharacteristicValueWrite data to the characteristic value.

Bluetooth

API NameFunction Description
my.openBluetoothAdapterUse this API to initialize the Bluetooth module in the mini program.
my.closeBluetoothAdapterUse this API to close the Bluetooth module in the mini program.
my.getBluetoothAdapterStateUse this API to check the Bluetooth adapter status in the mini program.
my.startBluetoothDevicesDiscoveryUse this API to start discovering bluetooth devices.
my.stopBluetoothDevicesDiscoveryUse this API to stop discovering bluetooth devices.
my.getBluetoothDevicesUse this API to get all the bluetooth devices that are discovered, including those that are connected to the current device.
my.getConnectedBluetoothDevicesUse this API to get the bluetooth devices that are connected.
my.onBluetoothDeviceFoundUse this API when a new Bluetooth device is found.
my.offBluetoothDeviceFoundUse this API to remove the bluetooth devices that are found.
my.onBluetoothAdapterStateChangeUse this API to monitor the bluetooth adapter state changes.
my.offBluetoothAdapterStateChangeUse this API to remove the bluetooth adapter with a state change.

web-view

API NameFunction Description
my.createWebViewContextBy creating webViewContext, Mini Program can send message to web-view. This API will create a webViewContext instance

Site Info

API NameFunction Description
my.getSiteInfoGet the site information.

Open Capabilities

API NameFunction Description
my.getAuthCodeGet auth code.
my.getOpenUserInfoGet basic information about user.
my.tradePayStart to pay.
my.navigateToMiniProgramJump to other Mini Program.
my.navigateBackMiniProgramReturn to the previous Mini Program, only when another Mini Program jumps to the current Mini Program.
my.signContractSign the withholding contract.
my.getPhoneNumberGet the phone number.

Experience Mini Program

Developers can use the Android Demo App to scan the QR code shown in the API documents.