wx.openSetting(Object object)
【使用場景】如訂閱的功能,用戶手動(dòng)設(shè)置關(guān)閉了“訂閱”,需引導(dǎo)用戶打開,則調(diào)用該方法跳轉(zhuǎn)設(shè)置頁,用戶再手動(dòng)開啟“訂閱”,方可使用。

訂閱20004.jpg
客戶端頁面展示,此處以騰訊健康小程序手動(dòng)打開設(shè)置頁的步驟為例,如下:
圖3就是wx.openSetting調(diào)起之后顯示的頁面,圖4是查看訂閱設(shè)置:

圖1.jpg

圖2.jpg

圖3.jpg

圖4.jpg
示例代碼
wx.requestSubscribeMessage({ //調(diào)用訂閱api
tmplIds: [''], //訂閱的模板id
success (res) { },
fail (res) { },
complete (res) {
if (res.errCode == 20004) {
wx.showModal({
title: '提示',
content: `您關(guān)閉了訂閱消息主開關(guān),無法進(jìn)行訂閱`,
// showCancel: false,
confirmText:"去開啟",
confirmColor:"#0091FF",
success (res) {
if (res.confirm) {
console.log('確認(rèn)框-用戶點(diǎn)擊 確認(rèn)')
wx.openSetting({ //跳轉(zhuǎn)設(shè)置頁開啟訂閱
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('確認(rèn)框-用戶點(diǎn)擊 取消')
}
}
})
}
},
})