wx.openSetting(Object object)
【使用场景】如订阅的功能,用户手动设置关闭了“订阅”,需引导用户打开,则调用该方法跳转设置页,用户再手动开启“订阅”,方可使用。
客户端页面展示,此处以腾讯健康小程序手动打开设置页的步骤为例,如下:
图3就是wx.openSetting调起之后显示的页面,图4是查看订阅设置:
示例代码
wx.requestSubscribeMessage({ //调用订阅api
tmplIds: [''], //订阅的模板id
success (res) { },
fail (res) { },
complete (res) {
if (res.errCode == 20004) {
wx.showModal({
title: '提示',
content: `您关闭了订阅消息主开关,无法进行订阅`,
// showCancel: false,
confirmText:"去开启",
confirmColor:"#0091FF",
success (res) {
if (res.confirm) {
console.log('确认框-用户点击 确认')
wx.openSetting({ //跳转设置页开启订阅
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('确认框-用户点击 取消')
}
}
})
}
},
})