Skip to main content
Version: 3.x

Taro.openSetting(option)

调起客户端小程序设置界面,返回用户设置的操作结果。设置界面只会出现小程序已经向用户请求过的权限

注意:2.3.0 版本开始,用户发生点击行为后,才可以跳转打开设置页,管理授权信息。详情

支持情况:

参考文档

类型

(option?: Option) => Promise<SuccessCallbackResult>

参数

参数类型
optionOption

Option

参数类型必填说明
withSubscriptionsboolean是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。
最低版本:2.10.3
complete(res: TaroGeneral.CallbackResult) => void接口调用结束的回调函数(调用成功、失败都会执行)
fail(res: TaroGeneral.CallbackResult) => void接口调用失败的回调函数
success(result: SuccessCallbackResult) => void接口调用成功的回调函数

SuccessCallbackResult

参数类型说明
authSettingAuthSetting用户授权结果
subscriptionsSettingSubscriptionsSetting用户订阅消息设置,接口参数 withSubscriptions 值为 true 时才会返回。
errMsgstring调用结果

示例代码

Taro.openSetting({
success: function (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})