/** requestSubscribeMessage Promisify * @param {Array<string>} tmplIds 需要订阅的消息模板的id的集合<=3 * @return {Array<boolean>|null} subscribeMessageStatus 用户对所有模板消息的对应的状态,一次可授权1-3个模板消息,返回[true,true,true],需真机环境 */ // API地址:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html function subscribeMessagePromisify(tmplIds) { return new Promise((resolve, reject) => { wx.requestSubscribeMessage({ tmplIds, success(res) { let result = []; tmplIds.forEach(i => { result.push(res[i] === "accept"); }); resolve(result); }, fail(error) { resolve(null); }, }); }); }
订阅消息是否能判断用户同意订阅/用户拒绝订阅?[图片] 怎么获取这个动态键的值,来判断用户是否同意
2022-05-06/** requestSubscribeMessage Promisify * @param {Array} tmplIds 需要订阅的消息模板的id的集合<=3 * @return {Array|null} subscribeMessageStatus 用户对所有模板消息的对应的状态,一次可授权1-3个模板消息,返回[true,true,true],需真机环境 */ // API地址:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html function subscribeMessagePromisify(tmplIds) { return new Promise((resolve, reject) => { wx.requestSubscribeMessage({ tmplIds, success(res) { let result = []; tmplIds.forEach(i => { result.push(res[i] === "accept"); }); resolve(result); }, fail(error) { resolve(null); }, }); }); }
订阅消息 wx.requestSubscribeMessage 为什么同意和拒绝 返回的都一样呢?wx.requestSubscribeMessage({ tmplIds: ['*****************-eyEy2KSNuy9fyIkV7HM'], success (res) { console.log(res) } })
2022-05-06不能延迟调用,即无法在await xxapi后调用,只能在bindtap之后立即调用
requestSubscribeMessage 无法调用?在界面上放置一个按钮,用于获取授权推送消息 <button bindtouchend="authMsg">授权金叶医生推送消息</button> 事件中是这么写得 [代码]authMsg(event) {[代码] [代码]wx.requestSubscribeMessage({[代码] [代码]tmplIds: [[代码][代码]'bPJUjgxTYg9yN3fn2tg4PaStW1I--DiZ7rr7KU8LQLo'[代码][代码]],[代码] [代码]success: [代码][代码]function[代码] [代码](res) {[代码] [代码] console.log(res)[代码] [代码]},[代码] [代码]fail: [代码][代码]function[代码] [代码](err) {[代码] [代码] console.log(err)[代码] [代码]}[代码] [代码]})[代码] [代码]},[代码] 但是提示错误 errMsg: "requestSubscribeMessage:fail can only be invoked by user TAP gesture." 这是为什么???
2022-05-06