收藏
回答

长期订阅消息,可以弹出授权多个吗?

长期订阅消息,单个可以弹出授权,两个就无法弹出了

回答关注问题邀请回答
收藏

3 个回答

  • Cjiang
    Cjiang
    2021-06-15

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2021-06-15
    有用
    回复
  • 赛文贝克
    赛文贝克
    2021-06-15
    const self = this;
        //叫号 JwvH4a9x****
        //物流 bju6OIp****
        let tmplIds = ['JwvH4a9x****','bju6OIp****'];
        wx.getSetting({
          withSubscriptionstrue//  这里设置为true,下面才会返回mainSwitch
          successfunction (res{
            // 调起授权界面弹窗
            if (res.subscriptionsSetting.mainSwitch) { // 用户打开了订阅消息总开关
              if (res.subscriptionsSetting.itemSettings != null) { // 用户同意总是保持是否推送消息的选择, 这里表示以后不会再拉起推送消息的授权
                console.log(res.subscriptionsSetting.itemSettings);
                let moIdState1 = res.subscriptionsSetting.itemSettings[tmplIds[0]]; // 用户同意的消息模板id
                if (moIdState1 === 'accept') {
                  console.log('叫号通知消息推送已开启');
                } else if (moIdState1 === 'reject') {
                  wx.showModal({
                    title'提示',
                    content'你已拒绝消息推送,将无法及时收到消息推送',
                    showCancelfalse,
                    success(res) {
    
    
                    }
                  })
                } else if (moIdState1 === 'ban') {
                  wx.showModal({
                    title'提示',
                    content'消息推送功能已被禁止,将无法及时收到消息推送',
                    showCancelfalse,
                    success(res) {}
                  })
                }
                let moIdState2 = res.subscriptionsSetting.itemSettings[tmplIds[1]]; // 用户同意的消息模板id
                if (moIdState2 === 'accept') {
                  console.log('物流状态通知消息推送已开启');
                } else if (moIdState2 === 'reject') {
                  wx.showModal({
                    title'提示',
                    content'你已拒绝消息推送,将无法及时收到消息推送',
                    showCancelfalse,
                    success(res) {
    
    
                    }
                  })
                } else if (moIdState2 === 'ban') {
                  wx.showModal({
                    title'提示',
                    content'消息推送功能已被禁止,将无法及时收到消息推送',
                    showCancelfalse,
                    success(res) {}
                  })
                }
              } else {
                // 当用户没有点击 ’总是保持以上选择,不再询问‘  按钮。那每次执到这都会拉起授权弹窗
                wx.showModal({
                  title'提示',
                  content'请授权开通消息推送',
                  showCanceltrue,
                  successfunction (ress{
                    if (ress.confirm) {
                      console.log(tmplIds);
                      wx.requestSubscribeMessage({ // 调起消息订阅界面
                        tmplIds: tmplIds,
                        success(res) {
                          console.log('订阅消息 成功 ');
                          console.log(res);
                        },
                        fail(er) {
                          console.log("订阅消息 失败 ");
                          console.log(er);
                        }
                      })
                    }
                  }
                })
              }
            } else {
              wx.showModal({
                title'提示',
                content'订阅消息未开启,将无法及时收到消息推送',
                showCancelfalse,
                success(res) {}
              })
            }
          },
          failfunction (error{
            console.log(error);
          },
        })
    
    2021-06-15
    有用
    回复
  • 微喵网络
    微喵网络
    2021-06-15

    上代码

    2021-06-15
    有用
    回复
登录 后发表内容