This API is called using Boolean wx.canIUse(string schema).
${API}.${method}.${param}.${options}
or ${component}.${attribute}.${option}
to call.Parameter | Description |
${API} | API name |
${method} | Call method. Valid values: return, success, object, callback |
${param} | Parameter or return value |
${options} | Optional values of the parameter |
${component} | Component name |
${attribute} | Component property |
${option} | Optional value of the component property |
wx.canIUse('openBluetoothAdapter')wx.canIUse('getSystemInfoSync.return.screenWidth')wx.canIUse('getSystemInfo.success.screenWidth')wx.canIUse('showToast.object.image')wx.canIUse('onCompassChange.callback.direction')wx.canIUse('request.object.method.GET')wx.canIUse('live-player')wx.canIUse('text.selectable')wx.canIUse('button.open-type.contact')
This API is called using wx.env.
This API is called using ArrayBuffer wx.base64ToArrayBuffer(string base64).
const base64 = 'CxYh'const arrayBuffer = wx.base64ToArrayBuffer(base64)
This API is called using string wx.arrayBufferToBase64(ArrayBuffer arrayBuffer).
const arrayBuffer = new Uint8Array([11, 22, 33])const base64 = wx.arrayBufferToBase64(arrayBuffer)
This API is called using wx.getUserInfo(Object object).
Property | Type | Default value | Required | Description |
success | Function | - | No | Callback function for successful API calls |
fail | Function | - | No | Callback function for failed API calls |
complete | Function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
Property | Type | Description |
brand | String | Device brand |
model | String | Device model |
pixelRatio | Number | Device pixel ratio |
screenWidth | Number | Screen width in px |
screenHeight | Number | Screen height in px |
windowWidth | Number | Available window width in px |
windowHeight | Number | Available window height in px |
statusBarHeight | Number | Status bar height in px |
language | String | Language |
version | String | Version number |
system | String | OS and version |
platform | String | Client platform. Valid values: iOS: including iPhone and iPad Android devtools: TCMPP developer tools |
fontSizeSetting | number | User font size in px |
SDKVersion | String | Base library version of the client |
AppPlatform | String | App platform |
safeArea | Object | Safe area in portrait mode |
theme | String | Current system theme. Value: Light or dark. Only available if darkmode:true Otherwise, it is undefined. |
Property | Type | Description |
left | Number | X-coordinate of the top-left corner of the safe area |
right | Number | X-coordinate of the bottom-right corner of the safe area |
top | Number | Y-coordinate of the top-left corner of the safe area |
bottom | Number | Y-coordinate of the bottom-right corner of the safe area |
width | Number | Width of the safe area in logical pixels |
height | Number | Height of the safe area in logical pixels |
wx.getSystemInfo({success(res) {console.log(res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)console.log(res.platform)}})
try {const res = wx.getSystemInfoSync()console.log(res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)console.log(res.platform)} catch (e) {// Do something when catch error}
This API is called using Object wx.getSystemInfoSync().
Property | Type | Description |
brand | String | Device brand |
model | String | Device model |
pixelRatio | Number | Device pixel ratio |
screenWidth | Number | Screen width in px |
screenHeight | Number | Screen height in px |
windowWidth | Number | Available window width in px |
windowHeight | Number | Available window height in px |
statusBarHeight | Number | Status bar height in px |
language | String | Language |
version | String | Version number |
system | String | OS and version |
platform | String | Client platform. Valid values: iOS: including iPhone and iPad Android devtools: TCMPP developer tools |
fontSizeSetting | number | User font size in px |
AppPlatform | String | App platform |
safeArea | Object | Safe area in portrait mode |
theme | String | Current system theme. Value: Light or dark. Only available if darkmode:true Otherwise, it is undefined. |
Property | Type | Description |
left | Number | X-coordinate of the top-left corner of the safe area |
right | Number | X-coordinate of the bottom-right corner of the safe area |
top | Number | Y-coordinate of the top-left corner of the safe area |
bottom | Number | Y-coordinate of the bottom-right corner of the safe area |
width | Number | Width of the safe area in logical pixels |
height | Number | Height of the safe area in logical pixels |
wx.getSystemInfo({success(res) {console.log(res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)console.log(res.platform)}})
try {const res = wx.getSystemInfoSync()console.log(res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)console.log(res.platform)} catch (e) {// Do something when catch error}
This API is called using wx.getSystemInfoAsync(Object object).
Property | Type | Default value | Required | Description |
success | function | - | No | Callback function for successful API calls |
fail | function | - | No | Callback function for failed API calls |
complete | function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
Property | Type | Description |
brand | string | Device brand |
model | string | Device model. New models may show as Unknown for a while until adapted |
pixelRatio | number | Device pixel ratio |
screenWidth | number | Screen width in px |
screenHeight | number | Screen height in px |
windowWidth | number | Available window width in px |
windowHeight | number | Available window height in px |
statusBarHeight | number | Task status bar height in px |
language | string | Language set in the app |
version | string | App version number |
system | string | OS and version |
platform | string | Client platform. Valid values: iOS: including iPhone and iPad Android devtools: IDE |
fontSizeSetting | number | User font size in px |
SDKVersion | string | Base library version of the client |
safeArea | object | Safe area in portrait mode. Some devices do not have a safe area concept and will not return the safeArea field. Developers need to handle this compatibility. For return values, see the table Return values of safeArea |
theme | string | The current system theme. The value can only be obtained when darkmode: true is set in global configuration. Otherwise, it is undefined (not supported in mini games). Valid values: Light: bright mode Dark: dark mode |
Structural property | Type | Description |
left | number | X-coordinate of the top-left corner of the safe area |
right | number | X-coordinate of the bottom-right corner of the safe area |
top | number | Y-coordinate of the top-left corner of the safe area |
bottom | number | Vertical coordinate of the lower right corner of the safe area |
width | number | Width of the safe area in logical pixels |
height | number | Height of the safe area in logical pixels |
wx.getSystemInfoAsync({success (res) {console.log(res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)console.log(res.platform)}})
This API is called using Object wx.getWindowInfo().
Property | Type | Description |
pixelRatio | number | Device pixel ratio |
screenWidth | number | Screen width in px |
screenHeight | number | Screen height in px |
windowWidth | number | Available window width in px |
windowHeight | number | Available window height in px |
statusBarHeight | number | Status bar height in px |
safeArea | object | Safe area in portrait mode. Some devices do not have a safe area concept and will not return the safeArea field. Developers need to handle this compatibility. |
screenTop | number | The y-coordinate of the top edge of the window |
Structural property | Type | Description |
left | number | X-coordinate of the top-left corner of the safe area |
right | number | X-coordinate of the bottom-right corner of the safe area |
top | number | Y-coordinate of the top-left corner of the safe area |
bottom | number | Vertical coordinate of the lower right corner of the safe area |
width | number | Width of the safe area in logical pixels |
height | number | Height of the safe area in logical pixels |
const windowInfo = wx.getWindowInfo()console.log(windowInfo.pixelRatio)console.log(windowInfo.screenWidth)console.log(windowInfo.screenHeight)console.log(windowInfo.windowWidth)console.log(windowInfo.windowHeight)console.log(windowInfo.statusBarHeight)console.log(windowInfo.safeArea)console.log(windowInfo.screenTop)
This API is called using Object wx.getSystemSetting().
Property | Type | Description |
bluetoothEnabled | boolean | Bluetooth permission |
locationEnabled | boolean | Location permission |
wifiEnabled | boolean | Wi-Fi permission |
deviceOrientation | string | Device orientation. Valid values: Portrait: Portrait mode Landscape: Landscape mode |
const systemSetting = wx.getSystemSetting()console.log(systemSetting.bluetoothEnabled)console.log(systemSetting.deviceOrientation)console.log(systemSetting.locationEnabled)console.log(systemSetting.wifiEnabled)
This API is called using wx.openSystemBluetoothSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | No | Callback function for successful API calls |
fail | function | - | No | Callback function for failed API calls |
complete | function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
wx.openSystemBluetoothSetting({success (res) {console.log(res)}})
This API is called using wx.openAppAuthorizeSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | No | Callback function for successful API calls |
fail | function | - | No | Callback function for failed API calls |
complete | function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
wx.openAppAuthorizeSetting({success (res) {console.log(res)}})
This API is called using Promise wx.getRendererUserAgent(Object object).
Property | Type | Default value | Required | Description |
success | function | - | No | Callback function for successful API calls |
fail | function | - | No | Callback function for failed API calls |
complete | function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
wx.getRendererUserAgent().then(userAgent => console.log(userAgent))wx.getRendererUserAgent({success(res) {console.log(res.userAgent)}})
This API is called using Object wx.getDeviceInfo().
Property | Type | Description |
abi | string | Host app's binary interface type (Android only) |
deviceAbi | string | Device’s binary interface type (Android only) |
benchmarkLevel | number | Device performance level (Android only). Valid values: -2 or 0: Mini games are not supported on the device. -1: Performance unknown. >=1: Device performance value (the max value is currently less than 50). The higher the value, the better the device performance. |
brand | string | Device brand |
model | string | Device model. New models may show as Unknown for a while until adapted |
system | string | OS and version |
platform | string | Client platform |
CpuType | string | Device CPU model (supported on Android only).The GPU model can be obtained using WebGLRenderingContext.getExtension('WEBGL_debug_renderer_info'). |
menorySize | string | Device memory size in MB |
const deviceInfo = wx.getDeviceInfo()console.log(deviceInfo.abi)console.log(deviceInfo.benchmarkLevel)console.log(deviceInfo.brand)console.log(deviceInfo.model)console.log(deviceInfo.platform)console.log(deviceInfo.system)
This API is called using Object wx.getAppBaseInfo().
Property | Type | Description |
SDKVersion | string | Base library version of the host client |
enableDebug | boolean | Whether debugging has been enabled. You can open the menu in the upper right corner, click Enable debugging or using setEnableDebug to enable debugging. |
host | Object | The host environment where the current mini program is running. The host environment where the current mini program is running. |
language | string | Language set on the host client |
version | string | Host client version number |
theme | string | The current system theme. Valid values: light: Bright mode, or dark: Dark mode. The value can only be obtained when darkmode: true is set in global configuration. Otherwise, it is undefined (not supported in mini games). |
const appBaseInfo = wx.getAppBaseInfo()console.log(appBaseInfo.SDKVersion)console.log(appBaseInfo.enableDebug)console.log(appBaseInfo.host)console.log(appBaseInfo.language)console.log(appBaseInfo.version)console.log(appBaseInfo.theme)
This API is called using Object wx.getAppAuthorizeSetting().
Property | Type | Description |
albumAuthorized | 'authorized'/'denied'/'not determined' | Gets the album permission info of the host client. (iOS only) |
bluetoothAuthorized | 'authorized'/'denied'/'not determined' | Gets the Bluetooth permission info of the host client. (iOS only) |
cameraAuthorized | 'authorized'/'denied'/'not determined' | Gets the camera permission info of the host client. |
locationAuthorized | 'authorized'/'denied'/'not determined' | Gets the location permission info of the host client. |
locationReducedAccuracy | boolean | Location accuracy. "True" indicates approximate location, while "false" indicates precise location (only available on iOS). |
microphoneAuthorized | 'authorized'/'denied'/'not determined' | Gets the microphone permission info of the host client. |
notificationAuthorized | 'authorized'/'denied'/'not determined' | Gets the notification permission info of the host client. |
notificationAlertAuthorized | 'authorized'/'denied'/'not determined' | Gets the reminder permission info of the host client. (iOS only) |
notificationBadgeAuthorized | 'authorized'/'denied'/'not determined' | Gets the notification badge permission info of the host client. (iOS only) |
notificationSoundAuthorized | 'authorized'/'denied'/'not determined' | Gets the sound notification permission info of the host client. (iOS only) |
phoneCalendarAuthorized | 'authorized'/'denied'/'not determined' | Gets the calendar permission info of the host client. |
const appAuthorizeSetting = wx.getAppAuthorizeSetting()console.log(appAuthorizeSetting.albumAuthorized)console.log(appAuthorizeSetting.bluetoothAuthorized)console.log(appAuthorizeSetting.cameraAuthorized)console.log(appAuthorizeSetting.locationAuthorized)console.log(appAuthorizeSetting.locationReducedAccuracy)console.log(appAuthorizeSetting.microphoneAuthorized)console.log(appAuthorizeSetting.notificationAlertAuthorized)console.log(appAuthorizeSetting.notificationAuthorized)console.log(appAuthorizeSetting.notificationBadgeAuthorized)console.log(appAuthorizeSetting.notificationSoundAuthorized)console.log(appAuthorizeSetting.phoneCalendarAuthorized)
This API is called using UpdateManager wx.getUpdateManager().
This method is called using UpdateManager.applyUpdate().
onUpdateReady
callback).This method is called using UpdateManager.onCheckForUpdate(function listener).
Property | Type | Description |
hasUpdate | Boolean | Checks if a new version is available |
This method is called using UpdateManager.onUpdateFailed(function listener).
This method is called using UpdateManager.onUpdateReady(function listener).
const updateManager = wx.getUpdateManager()updateManager.onCheckForUpdate(function (res) {// Callback upon requesting new version informationconsole.log(res.hasUpdate)})updateManager.onUpdateReady(function () {wx.showModal({title: 'Update prompt',content: 'The new version is ready. Do you want to restart the application?',success(res) {if (res.confirm) {// The new version has been downloaded. Call applyUpdate to apply the new version and restart.updateManager.applyUpdate()}}})})updateManager.onUpdateFailed(function () {// New version download failed})
This API is called using Object wx.getLaunchOptionsSync().
referrerInfo
may return undefined
if not present. It is recommended to check using options.referrerInfo && options.referrerInfo.appId
.Property | Type | Description |
path | String | The path of the mini program startup |
scene | Number | Scene value for starting up the mini program. Default value: 1001 |
query | Object | Query parameter for starting up the mini program |
referrerInfo | Object | The referrer of the information, returned when entering a mini program from another mini program or an app. Otherwise, it returns {}. |
forwardMaterials | Array.<Object> | An array of opened file information |
Property | Type | Description |
appId | String | The referrer's AppID for the mini-program or app |
extraData | Object | Data passed from the referrer of the mini program |
[[TMFMiniAppSDKManager sharedInstance] startUpMiniAppWithAppID:@"mpbz0uqwzddj5zbt" scene:TMAEntrySceneNone firstPage:nil paramsStr:@"a=1&b=2" parentVC:self completion:^(NSError * _Nullable err) {}];
MiniStartLinkOptions miniStartOptions = new MiniStartLinkOptions(); miniStartOptions.params = (String) options.get("params");public static void startMiniApp(Activity activity, String appId, MiniStartOptions options) { startMiniApp(activity, appId, 1001, 0, options);}
Property | Type | Description |
type | string | The MIME type of the file |
name | Object | File name |
path | string | File path |
size | number | File size |
referrerInfo
returnedProperty | Type | Description |
The referrer of the app | ||
1037 | Opens the mini program from another mini program | The referrer of the mini program |
1038 | Returns from another mini program | The referrer of the mini program |
This API is called using Object wx.getEnterOptionsSync().
referrerInfo
may return undefined
if not present. It is recommended to check using options.referrerInfo && options.referrerInfo.appId
.Property | Type | Description |
path | string | The path of the mini program startup (code package path) |
scene | number | The scene value of the mini program startup |
query | Object | The query parameter of the mini program startup |
shareTicket | string | shareTicket |
referrerInfo | Object | The referrer of the information. Returned when entering the mini program from another mini program, WeChat official account, or an app. Otherwise, {} is returned. For details, see the notes above the table. |
forwardMaterials | Array.<Object> | An array of opened file information |
Property | Type | Description |
appId | String | The referrer's AppID for the mini-program or app |
extraData | Object | Data passed from the referrer of the mini program |
Property | Type | Description |
type | String | The MIME type of the file |
name | Object | File name |
path | String | File path, or URL if using web-view component |
size | Number | File size |
Property | Type | Description |
1037 | Opens the mini program from another mini program | The referrer of the mini program |
1038 | Returns from another mini program | The referrer of the mini program |
This API is called using wx.onError(function callback).
This API is called using wx.offError(function callback).
This API is called using wx.onThemeChange(function listener).
Property | Valid values and descriptions | Type | Description |
theme | Dark: Dark theme Light: Light theme | String | The current theme of the system, with the value is light or dark. |
This API is called using wx.offThemeChange(function listener).
const listener = function (res) { console.log(res) }wx.onThemeChange(listener)wx.offThemeChange(listener) // Pass the same function object used for listening.
This API is called using wx.onPageNotFound(function listener).
Property | Type | Description |
path | string | The path of the non-existent page (code package path). |
query | Object | Query parameter for opening a non-existent page |
isEntryPage | boolean | Whether it is the first page of this startup (for example, when entering from a shared link, the first page is the share page configured by the developer) |
This API is called using wx.offPageNotFound(function listener).
const listener = function (res) { console.log(res) }wx.onPageNotFound(listener)wx.offPageNotFound(listener) // Pass the same function object used for listening.
This API is called using wx.onAppShow(function listener).
options.referrerInfo && options.referrerInfo.appId
.Property | Type | Description |
path | string | The path of the mini program startup (code package path) |
scene | number | The scene value of the mini program startup |
query | Object | The query parameter of the mini program startup |
shareTicket | string | shareTicket |
referrerInfo | Object | The referrer of the information. Returned when the mini program is accessed from another mini program or an app. Otherwise, {} is returned. For details, see the notes above the table. |
forwardMaterials | Array.<Object> | An array of opened file information |
Property | Type | Description |
appId | string | The referrer's AppID for the mini-program or app |
extraData | Object | Data passed from the referrer of the mini program |
Property | Type | Description |
type | String | The MIME type of the file |
name | Object | File name |
path | String | File path, or URL if using web-view component |
size | Number | File size |
Scene value | Scene | Description |
1037 | Opens the mini program from another mini program | The referrer of the mini program |
1038 | Returns from another mini program | The referrer of the mini program |
This API is called using wx.offAppShow(function listener).
const listener = function (res) { console.log(res) }wx.onAppShow(listener)wx.offAppShow(listener) // Pass the same function object used for listening.
This API is called using wx.onAppHide(function listener).
The API is called using wx.offAppHide(function listener).
const listener = function (res) { console.log(res) }wx.onAppHide(listener)wx.offAppHide(listener) // Pass the same function object used for listening.
This API is called using wx.onUnhandledRejection(function listener).
Property | Type | Description |
reason | string | Rejection reason, typically an Error object |
promise | Promise.<any> | The rejected Promise object |
This API is called using wx.offUnhandledRejection(function listener).
const listener = function (res) { console.log(res) }wx.onUnhandledRejection(listener)wx.offUnhandledRejection(listener) // Pass the same function object used for listening.
This API is called using wx.setEnableDebug(Object object).
Property | Type | Default value | Required | Description |
enableDebug | boolean | - | Yes | Whether to enable debugging |
success | function | - | No | Callback function for successful API calls |
fail | function | - | No | Callback function for failed API calls |
complete | function | - | No | Callback function executed when the API call is complete (regardless of success or failure) |
// Enable debuggingwx.setEnableDebug({enableDebug: true})// Disable debuggingwx.setEnableDebug({enableDebug: false})
This API is called using RealtimeLogManager wx.getRealtimeLogManager().
// For the mini programconst logger = wx.getRealtimeLogManager()logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])logger.error({str: 'hello world'}, 'error log', 100, [1, 2, 3])logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])// For the plugin. Supported on the basic library 2.16.0 and later versions, and only reporting in the new key-value format is allowed.const logManager = wx.getRealtimeLogManager()const logger = logManager.tag('plugin-log1')logger.info('key1', 'value1')logger.error('key2', {str: 'value2'})logger.warn('key3', 'value3')
Th is API is called using LogManager wx.getLogManager(Object object).
Property | Type | Default value | Required | Description |
level | number | 0 | No | The valid values are 0 and1, where 0 indicates the that the lifecycle functions of App and Page , as well as function calls under the namespace, will be logged. A value of 1 means they will not be logged. The default value is 0. |
const logger = wx.getLogManager({level: 1})logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])logger.debug({str: 'hello world'}, 'debug log', 100, [1, 2, 3])logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
This method is called using console.debug()
This method is called using console.error().
This method is called using console.group().
This method is called using console.groupEnd().
This method is called using console.info.
This method is called using console.log().
This method is called using console.warn().
This method is called using LogManager.debug().
This method is called using LogManager.info().
This method is called using LogManager.log().
This method is called using LogManager.warn().
<Button>
component’s open-type="feedback"
to upload the printed logs. Developers can view the feedback on the "User feedback" page on the mini program management backend.App
and Page,
, and calls of functions under the namespace into the log.This method is called using RealtimeLogManager.addFilterMsg(string msg).
This method is called using RealtimeLogManager.error().
This method is called using Object RealtimeLogManager.getCurrentState().
Property | Type | Description |
size | number | The space already used in the current cache in bytes |
maxSize | number | The maximum available space in the current cache in bytes |
logCount | number | The number of log entries in the current cache |
maxLogCount | number | The maximum number of log entries that can be stored in the current cache |
This method is called using RealtimeLogManager.in(Page pageInstance).
This method is called using RealtimeLogManager.info().
This method is called using RealtimeLogManagersetFilterMsg(string msg).
This method is called using RealtimeLogManager.warn().
This method is called using RealtimeTagLogManager.addFilterMsg(string msg).
This method is called using RealtimeTagLogManager.error(string key, Object]Array.<any> number string value).
This method is called using RealtimeTagLogManager.info(string key, Object Array.<any> number string value).
This method is called using RealtimeTagLogManager.setFilterMsg(string msg).
This method is called using RealtimeTagLogManager.warn(string key, ObjectJArray.< any> number string value).
Was this page helpful?