微信小程序订阅消息

微信小程序订阅消息

官网步骤

详情见:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html

遇到的问题

1.调用用户授权接口报错:
wx.requestSubscribeMessage is not a function
查找资料,发现要求调试基础库要大于2.8.2;
如何修改调试基础库呢?
解决方案:微信小程序开发者工具-详情-本地设置-调试基础库选择大于2.8.2的版本
在这里插入图片描述

2.调用事件报错:(目前必须要手动点击调用)

requestSubscribeMessage:fail can only be invoked by user TAP gesture
翻译:errMsg:“请求订阅”beMessage:故障can只能由用户点击手势调用。“

如:

  subscribeNew:function(){
  wx.requestSubscribeMessage({
    tmplIds: ['BNSOZGVBgUcvlYhOOLakaFVvXFqoacRVMPMDkj5fTzs'],
    success(res) { 
      console.log(res,"成功")
    },
    fail(fail){
      console.log(fail,"失败")
    }
  })
},
     <button bindtap="subscribeNew"> 订阅消息</button>
参考

https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html

https://www.cnblogs.com/msunh/p/12175555.html

https://www.jianshu.com/p/0853e36925e3

https://blog.csdn.net/zl18603543572/article/details/108089977

服务端:https://blog.csdn.net/songguopeng/article/details/103772604

https://www.cnblogs.com/msunh/p/11762573.html

前后详细步骤:https://kingyifan.blog.csdn.net/article/details/103888343?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control&dist_request_id=&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值