# wx.getSetting(Object object)
Start from base library version 1.2.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.6.3
When used in a Mini Program plug-in, the interface differs as follows:
withSubscriptionsInvalid (plug-in has no subscription message for now)In the return value
authSettingField is the permission of the plug-in (such as user information feature page authorization)2.14.0 The return value is
miniprogramAuthSettingField, content equal to the current Mini ProgramgetSettingResults (without subscription status)
Gets the user's current settings.In the return value, only what the Mini Program has already requested from the userJurisdiction。
# parameter
# Object object
| attribute | type | Default values | Required | Introductions | Minimum version |
|---|---|---|---|---|---|
| withSubscriptions | Boolean | false | no | Whether to get the subscription status of the user's subscription message at the same time. Note: with Subscriptions Only returns a subscription message where the user has checked "Always keep above selection, no longer ask" in the subscription panel. | 2.10.1 |
| success | function | no | Interface calls the successful callback function | ||
| fail | function | no | Interface calls failed callback functions | ||
| complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
# object.success callback
# parameter
# Object res
| attribute | type | Introductions | Minimum version |
|---|---|---|---|
| authSetting | AuthSetting | User Authorization Results | |
| subscriptionsSetting | SubscriptionsSetting | User subscription message settings, interface parameterswithSubscriptionsValue istrueWill return only when. | 2.10.1 |
| miniprogramAuthSetting | AuthSetting | The user authorization result of the current host Mini Program when invoked in the plug-in |
# sample code
wx.getSetting({
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
wx.getSetting({
withSubscriptions: true,
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
console.log(res.subscriptionsSetting)
// res.subscriptionsSetting = {
// mainSwitch: true, // Subscription message master switch
// itemSettings: { // Every switch
// SYS_MSG_TYPE_INTERACTIVE: 'accept', // Small game system subscription message
// SYS_MSG_TYPE_RANK: 'accept'
// zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: 'reject', // General one-time subscription messages
// Wed_OZC_66gZxALLcsuI7ilCJSP2OJ2vWo2ooUPpkWrw: "Class"
// }
// }
}
})