收藏
回答

体验版无法弹出订阅窗口?

开发工具中订阅消息可以弹窗,发布到体验版点击无法弹窗,调试进入  wx.requestSubscribeMessage没任何反馈

  let ids = []; 

        ids.push('--0fII-iwGRqAYToi8cBLj6QpjBp3Qdb4KhnB7MY2aA');

        if (code.indexOf("CX">= 0{

            ids.push('E3mBGrMx1L64jQRtZDs_xL4Cw0CH46Lr4ToRopWf0Oo');

        }

        wx.getSetting({

            withSubscriptions: true,

            success(res) {

                console.logres)

                if (res.subscriptionsSetting.mainSwitch{ // 用户打开了订阅消息总开关

                    if (res.subscriptionsSetting.itemSettings{ // 用户同意总是保持是否推送消息的选择, 这里表示以后不会再拉起推送消息的授权  

                        let itemSettings = res.subscriptionsSetting.itemSettings; 

                        //判断模板是否全部授权

                        let status = false;

                        for (let i = 0; i < ids.length; i++{

                            let key = ids[i];

                            let moIdState = itemSettings[key]

                            if (moIdState == 'accept'{

                                status = true;

                                if (moIdState === 'ban'{

                                    console.log("已被后台封禁");

                                    callBack(false);

                                }

                                break;

                            }

                        }

                        if (status{

                            console.log("回调True");

                            callBack(true);

                        } else if (moIdState === 'reject'{

                            wx.requestSubscribeMessage({

                                tmplIds: ids,

                                success(res) {

                                    console.log("订阅消息请求成功");

                                    callBack(true);

                                },fail(err) {

                                    console.error('订阅消息请求失败:', err);

                                  } 

                            })

                        }  

                    } else {

                        console.log("回调itemSettings False");

                        wx.requestSubscribeMessage({

                            tmplIds:ids,

                            success(res) {

                                console.log("订阅消息请求成功");

                                callBack(true);

                            },fail(err) {

                                console.error('订阅消息请求失败:', err);

                              } 

                        })

                    }

                } else {

                    wx.openSetting({

                        withSubscriptions: true,

                    })

                    // console.log("回调True");

                    // callBack(true);

                }

            }

        })

    },


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

3 个回答

  • H1HAO 🇨🇳
    H1HAO 🇨🇳
    18小时前

    打印ids并且先把外层的getSetting注释掉默认直接使用requestSubscribeMessage试试

    我这边测试体验版正常

    var subscriptionId ='xxx'
    wx.requestSubscribeMessage( {
    						tmplIds: [ subscriptionId ],
    						success( res ) {
    							var subscriptionStatus = res[ subscriptionId ]
    							if ( subscriptionStatus == 'accept' ) {
    								console.log( "同意订阅" )
    
    							} else if ( subscriptionStatus == 'reject' ) {
    								console.log( "拒绝订阅" )
    							} else if ( subscriptionStatus == 'ban' ) {
    								console.log( "订阅模板被封禁" )
    							} else if ( subscriptionStatus == 'filter' ) {
    								console.log( "已订阅相同模板" )
    							}
    				
    						},
    						fail( err ) {
    							console.log( "订阅失败:", err )
    						}
    					} )
    
    18小时前
    有用
    回复
  • 王兴波
    王兴波
    20小时前

    没报什么错误


    20小时前
    有用
    回复
  • 一笑皆春
    一笑皆春
    21小时前

    体验版打开手机右上角的调试,看看控制台报什么错

    21小时前
    有用
    回复
登录 后发表内容