
微信小程序 订阅消息,突然不弹同意框了{errMsg: “requestSubscribeMessage:fail No template data return,...
推送消息询问
·
报错:{errMsg: "requestSubscribeMessage:fail No template data return, verify the template id exist", errCode: 20001}
上面的意思是,template id 不存在,但是在小程序后台看了,订阅消息中确实是存在的。
//主动询问订阅消息
onNotifyAsk(callback) {
let tempId = this.data.tempIds;
wx.requestSubscribeMessage({
tmplIds: tempId,
success: res => {
console.log('调起成功');
if (res[tempId[0]] === 'accept') {
console.log('允许');
callback('accept')
}
if (res[tempId[0]] === 'reject') {
console.log('拒绝')
callback('reject')
}
},
fail: err => {
callback('error');
console.log(err)
if (err.errCode == 20004) {
console.log('关闭小程序主开关')
} else {
console.log('订阅失败')
}
}
});
},
tempIds: ['dlcx-N6lY-kDe_7uOO5lI6qcoxFs2Cdc62t6GIxPD0I'],
以上是之间的代码,现在无法正常工作。
修改以后的代码可以正常工作:
//主动询问订阅消息
onNotifyAsk(callback) {
let tempId = this.data.tempIds;
wx.requestSubscribeMessage({
tmplIds: ['dlcx-N6lY-kDe_7uOO5lI6qcoxFs2Cdc62t6GIxPD0I'],
success: res => {
console.log('调起成功');
if (res['dlcx-N6lY-kDe_7uOO5lI6qcoxFs2Cdc62t6GIxPD0I'] === 'accept') {
console.log('允许');
callback('accept')
}
if (res['dlcx-N6lY-kDe_7uOO5lI6qcoxFs2Cdc62t6GIxPD0I'] === 'reject') {
console.log('拒绝')
callback('reject')
}
},
fail: err => {
callback('error');
console.log(err)
if (err.errCode == 20004) {
console.log('关闭小程序主开关')
} else {
console.log('订阅失败')
}
}
});
},
以上把信息写死,竟然可以了。
更多推荐
所有评论(0)