app一次性订阅消息没有回调。求帮助!
发布于 5 年前 作者 jie78 5405 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图):  可以拉起app授权订阅页面,但点击确认没有回调。

public void onResp(BaseResp resp) {  这函数没有回调


  • 预期表现 :应该是回调返回openid值
  • 复现路径
  • 提供一个最简复现 Demo
    launchBtn = (Button) findViewById(R.id.launch_wx_btn);
launchBtn.setOnClickListener(new View.OnClickListener() {

[@Override](/user/Override)
public void onClick(View v) {
SubscribeMessage.Req req = new SubscribeMessage.Req();
req.scene = 102;
req.templateID = "1Dki3Ou74I-U70Ho-IEe73FR-0jSPiQRf8HwDYjtr44"; //app tempid
req.reserved = "ddsdfsd";

api.sendReq(req);

}



public void onResp(BaseResp resp) { //这个函数没有回调到,,昨天好像回调了一次,bdu下说是
//req.scene 值要改变有回调的,但用同一个授权过微信号也是没有回调
   Log.e( "20180228", "onClick: 22222222" );

int result = 0;
if(resp.getType() == ConstantsAPI.COMMAND_SUBSCRIBE_MESSAGE){

Log.i("20180228", "here come to resp method successful...."+resp+"-->"+resp.openId+"<-ddd->");
if(resp.errCode ==0)
{
String openid = resp.openId;
String url = "https://api.weixin.qq.com/cgi-bin/message/template/subscribe?access_token="+accessToken;
JSONObject param = new JSONObject();
try {
param.put("touser", openid);
param.put("template_id", "1Dki3Ou74I-U70Ho-IEe73FR-0jSPiQRf8HwDYjtr44");
param.put("scene", "102");
param.put("title", "我是消息标题");

JSONObject content = new JSONObject();
content.put("value", "老司机开车");
content.put("color", "#FF0000");
JSONObject data = new JSONObject();
data.put("content", content);

param.put("data", data);

} catch (JSONException e) {
e.printStackTrace();
} finally {
}
}

}
}

Toast.makeText(this, result, Toast.LENGTH_LONG).show();
}


1 回复

能否详细一下,你这个订阅消息的调用的接口是?

回到顶部