美文网首页
uni-app 微信小程序 订阅消息通知

uni-app 微信小程序 订阅消息通知

作者: 郭的妻 | 来源:发表于2022-05-14 09:34 被阅读0次

    1.在微信小程序管理平台点击订阅消息,并设置好 订阅消息 的 模板消息

    image.png

    2.让后端写好获取模板id的接口

    3.调取后端接口 前端调起 订阅消息通知 是否允许 弹窗

    注意 uni.requestSubscribeMessage

    /* 获取是否允许通知 */
    GetTemplateMessage() {
       let data = {
           scene:this.detail.item_lists[this.arr_index].is_reserve == 1 ? 1 : 2,
       };
       this.$u.api.GetTemplateMessage(data).then(res => {
            console.log("获取是否允许通知----", res);
            if (res.code == 200) {
               uni.requestSubscribeMessage({
                  tmplIds: res.content.template_id, //数组格式
                     success:(res1)=> {}
               })
            }
       });
    },
    

    相关文章

      网友评论

          本文标题:uni-app 微信小程序 订阅消息通知

          本文链接:https://www.haomeiwen.com/subject/ljmyurtx.html