my.getSetting

Use this API to obtain the user's current settings. Only the permissions that have been requested by the Mini Program from the user are returned.

Sample Code

copy
my.getSetting({
  success: (res) => {
    /*
     * res.authSetting = {
     *   "location": true,
     *   "audioRecord": true,
     *   ...
     * }
     */
  }
})

Parameters

PropertyTypeRequiredDescription
successFunctionNoThe callback function for a successful API call. See Sample Return Value for details.
failFunctionNoThe callback function for a failed API call.
completeFunctionNoThe callback function used when the API call is completed. This function is always executed no matter the call succeeds or fails.

Success callback function

PropertyTypeDescription
authSetting ObjectResults of user authorization. Keys are the values of scopes and values are boolean types, which shows whether the user gives the permission or not. See Scopes for details.

Return Value Sample

copy
{
    "authSetting": {
        "camera": true,
        "location": true,
        "album": true,
        "userInfo": true,
        "phoneNumber": true
    }
}

Scopes

ScopeAPIDescription
locationmy.getLocationThis field specifies whether to authorize access to geographic location. 
albummy.chooseImagemy.saveImageThis field specifies whether to authorize to save images to the albums.
cameramy.scanThis field specifies whether to authorize access to camera.
phoneNumbermy.getPhoneNumberThis field specifies whether to authorize access to phone number.
userInfomy.getOpenUserInfoThis field specifies whether to authorize access to user information.