微信一次性訂閱訊息接入問題解析

來源:互聯網
上載者:User
本文主要和大家分享一次性訂閱訊息接入問題解析,環境都已經接入,發送 一次性訂閱訊息 授權:

 final IWXAPI api = WXAPIFactory.createWXAPI(SettingActivity.this, response.getAppId());                // 將該app註冊到                api.registerApp(ServerUrls.WEIXIN_APP_ID);                Log.i("20180228", "come to send request with subscribeMessage....");                SubscribeMessage.Req req = new SubscribeMessage.Req();                req.templateID = response.getTemplateId();                req.scene = 889;//                req.reserved = response.getReserved();                Log.i("20180228", "req.appId: "+response.getAppId());                Log.i("20180228", "req.templateId: "+req.templateID);//                Log.i("20180228", "req.scene: "+req.scene);//                Log.i("20180228", "req.reserved: "+req.reserved);                Log.i("20180228", "before send request: "+req.toString());                boolean sendResult = api.sendReq(req);                Log.i("20180228", "after send request: "+sendResult);                ToastUtils.show(SettingActivity.this, "發送請求結束");

在授權頁面的回調中做簡單的處理:

@Override    public void onResp(BaseResp resp) {        Log.i("20180228", "here come to the resp with wechat request: "+resp.toString());        Log.i("20180228", "here come to the resp with wechat errCode: "+resp.errCode);        Log.i("20180228", "here come to the resp with wechat errStr: "+resp.errStr);        Log.i("20180228", "here come to the resp with wechat openId: "+resp.openId);        Log.i("20180228", "here come to the resp with wechat type: "+resp.getType());        ToastUtils.show(this, "openId: "+resp.openId);        if(resp.getType() == ConstantsAPI.COMMAND_SUBSCRIBE_MESSAGE){            Log.i("20180305", "here come to resp method successful....");        }//        if (resp.getType() == ConstantsAPI.COMMAND_SENDAUTH && resp.errCode == BaseResp.ErrCode.ERR_OK){//            ToastUtils.show(this, "request auth here ....");//            String openId = resp.openId;//            int errCode = resp.errCode;//            String errString = resp.errStr;////            new UserManager(this).bidnWXRSS(openId, new SimpleCallback<ApiResponse>() {//                @Override//                public void onSuccess(ApiResponse response) {//                    ToastUtils.show(WXEntryActivity.this, "綁定成功!");//                    finish();//                }//            });//        }        finish();    }

在開啟的調試列印中顯示:

03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleIntent, cmd = 403-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXMediaMessage: pathOldToNew, oldPath = com.tencent.mm.sdk.openapi.WXAppExtendObject03-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType, extInfo = wx_internal_resptype=subscribemessage&openid=oerX_woJRjvv8NzuUJHcKJe5PzwU&template_id=H0tXdBxs_ea5bVofycFBUPZl3hRgLWHxJIVBEYhSnxQ&action=confirm&reserved=null&scene=88903-05 17:46:00.967 10706-10706/com.xxx I/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType, respType = null03-05 17:46:00.967 10706-10706/com.xxx E/MicroMsg.SDK.WXApiImplV10: handleWxInternalRespType fail, respType is null

handleIntent()的時候,返回的是false,也沒法調用onResp方法,其中的原因是因為上面的respType = null,但是上面發現extInfo是有資料的,並且可以看出wx_internal_resptype=subscribemessage。

這邊查看WXApiImplV10.class,部分代碼如下:


也就是說,這邊的respType=subscribemessage,但是上面解析出來變成了null, 其中關鍵的代碼是:


然後才明白,這邊的extInfo字串的起始處少了一個“?”,所以把extInfo解析成Uri後,就找不到指定的“wx_internal_resptype”屬性了。所以頁面會卡在WXEntryActivity頁面沒有進行下一步的操作,這邊希望Team Dev可以儘早處理!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.