This API is called using wx.login(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.login({success(res) {console.log(res ,"---------------info, host app return");}})
This API is called using wx.checkSession(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.checkSession({success () {// The session_key has not expired and remains valid for this lifecycle.},fail () {// The session_key has expired, and the login process needs to be executed again.wx.login() // Log in again.}})
This API is called using Object wx.getAccountInfoSync().
Property | Type | Description |
miniProgram | Object | Mini game account information. |
Structural property | Type | Description |
appId | string | Mini game appid. |
envVersion | string | Mini game version. Valid values: develop: The development version trial: The preview release: The released version |
version | string | Online mini game version number. |
This API is called using wx.getUserInfo(Object object).
Property | Type | Default value | Required | Description |
lang | string | en | False | The language used to display the user information. Valid values: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
userInfo | UserInfo | User information object. |
// This must be called only after the user has granted authorizationwx.getUserInfo({success: function(res) {var userInfo = res.userInfovar nickName = userInfo.nickNamevar avatarUrl = userInfo.avatarUrl}})
Property | Type | Description |
nickName | string | User’s nickname. |
avatarUrl | string | The URL of the user's profile photo. The last number in the URL represents the size of the square profile photo (0, 46, 64, 96, 132 are available to choose from. 0 represents a 640 × 640 profile photo, 46 represents a 46 × 46 profile photo, and so on. The default value is 132.) This field is left blank if the user has no profile photo. If the user changes the profile photo, the original profile photo URL will become invalid. |
gender | number | User's gender. This will no longer be returned. Valid values: 0: Unknown 1: Male 2: Female |
country | string | The user’s country. This will no longer be returned. |
province | string | The user's province. This will no longer be returned. |
city | string | The user's city. This will no longer be returned. |
language | string | The language used to display the country, province, and city. It will always return "zh_CN". Valid values are: en: English zh_CN: Simplified Chinese zh_TW: Traditional Chinese |
Property | Description |
boolean scope.userInfo | Whether the user has authorized access to their information. Corresponds to wx.getUserInfo. |
boolean scope.writePhotosAlbum | Whether the user has authorized saving images to their photo album. Corresponds to wx.saveImageToPhotosAlbum. |
boolean scope.userLocation | Whether the user has authorized access to their precise location. Corresponds to wx.getLocation. |
boolean scope.userFuzzyLocation | Whether the user has authorized access to their approximate location. Corresponds to wx.getFuzzyLocation. |
This API is called using wx.getSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
authSetting | User authorization result. |
wx.getSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is called using wx.openSetting(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
authSetting | AuthSetting | User authorization result. |
wx.openSetting({success(res) {console.log(res.authSetting)// res.authSetting = {// "scope.userInfo": true,// "scope.userLocation": true// }}})
This API is called using wx.authorize(Object object).
Property | Type | Default value | Required | Description |
scope | string | - | True | |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
// You can use wx.getSetting to check if the user has authorized the "scope.userLocation" scopewx.getSetting({success(res) {if (!res.authSetting['scope.userLocation']) {wx.authorize({scope: 'scope.userLocation',success() {wx.getLocation()}})}}})
This API is called using wx.requirePrivacyAuthorize(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.requirePrivacyAuthorize({success: () => {// The user agrees to the authorization// runGame() continues the game logic},fail: () => {}, // The user disagrees to the authorizationcomplete: () => {}})
This API is called using wx.onNeedPrivacyAuthorization(function listener).
Property | Type | Description |
referrer | string | The name of the API or component that triggered this onNeedPrivacyAuthorization event (e.g. “getUserInfo”). |
Property | Type | Description |
event | string | The type of user actions. |
event | Description |
exposureAuthorization | Exposure of custom privacy pop-up window. |
agree | User agrees to privacy authorization. |
disagree | The user denies the privacy authorization. |
wx.onNeedPrivacyAuthorization((resolve, eventInfo) => {console.log('The API that triggered this event is ' + eventInfo.referrer)// ------ Custom pop-up logic ------ //showCustomPopup()// -------After the pop-up, based on user actions, execute the following logic ------- //// Developers display a custom privacy pop-up and call resolve to inform the superapp that the pop-up has been shownresolve({ event: 'exposureAuthorization' })// After the user taps Agree, the developer calls resolve to inform the superapp about the user’s authorization.resolve({ event: 'agree' })// After the user taps Deny, the developer calls resolve to inform the superapp that the user has denied the authorization.resolve({ event: 'disagree' })})
This API is called using wx.requestSubscribeMessage(Object object).
Property | Type | Required | Description |
tmplIds | Array<string> | True | Array of message template IDs to subscribe to. A maximum of 3 messages can be subscribed to in one call. Each tmplId must correspond to a unique template title, otherwise duplicates will be filtered out. The message template ID is configured under Mini game management - Message subscription. |
success | function | False | Callback function for successful API calls. |
fail | function | False | Callback function for failed API calls. |
complete | function | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
errMsg | string | The value of errMsg is 'requestSubscribeMessage:ok' when the API is called successfully. |
[TEMPLATE_ID: string] | string | [TEMPLATE_ID] is a dynamic key representing the template ID. The value can be 'accept', 'reject', 'ban', or 'filter'. 'accept': The user agreed to subscribe to the message corresponding to this template ID. 'reject': The user refused to subscribe to the message corresponding to this template ID. 'ban': The template has been banned by SAS. 'filter': The template was filtered out by SAS due to duplicate titles. For example, { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} indicates that the user has agreed to subscribe to the message zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE. |
Property | Type | Description |
errMsg | string | Error message when the API call fails. |
errno | Number | Error code when the API call fails. |
errCode | errMsg | Description |
10001 | TmplIds can't be empty | The tmplIds parameter is empty. |
10002 | Request list fail | Network error. Failed to request the message list. |
10003 | Request subscribe fail | Network error. Failed to send the subscription request. |
20001 | No template data return, verify the template id exist | No template data, usually because the template ID does not exist or does not match the template type. |
20002 | Templates type must be same | The template messages include both temporary and permanent types. |
20003 | Templates count out of max bounds | The number of template messages exceeds the limit. |
20004 | The main switch is switched off | The user has turned off the main switch, preventing subscriptions. |
20005 | This mini program was banned from subscribing messages | The mini program is banned from subscribing to messages. |
20013 | Reject DeviceMsg Template | Subscription to device messages using this API is not allowed. |
wx.requestSubscribeMessage({tmplIds: [''],success: (res) => {console.log('requestSubscribeMessage===success', res)res === {errMsg: "requestSubscribeMessage:ok","zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE": "accept"}}})
Feedback