之前使用百度云推送出现了一个问题,从百度推送平台推送的消息在客户端可以正常接收到,但是在后台以JSON串传递的话却出现了客户端接收到的customContentString一直为null的情况。但是IOS端却是一直OK的,这不禁又产生了撕逼的情况。认真看了下文档,
由此可见Android的通知格式跟IOS是不一样的,必须要加入custom_content的格式,而且必须是JSON格式的。
后台数据的格式如下:
//ANDROID 封装
JSONObject androidJson = new JSONObject();
JSONObject a = new JSONObject();
a.put("sendId", sendId);
a.put("type", SystemConstant.NOTICE_MSG_TYPE);//普通通知
androidJson.put("custom_content", a);
androidJson.put("description",sendNoticeTitle);
androidJson.put("title", sendNoticeTitle);
//androidJson.put("notification_builder_id",0);
JSONObject androidJson = new JSONObject();
JSONObject a = new JSONObject();
a.put("sendId", sendId);
a.put("type", SystemConstant.NOTICE_MSG_TYPE);//普通通知
androidJson.put("custom_content", a);
androidJson.put("description",sendNoticeTitle);
androidJson.put("title", sendNoticeTitle);
//androidJson.put("notification_builder_id",0);
这样的内容格式才算是正确的,经过测试,客户端接受到的是正确的数据,然后对内容进行解析就Ok了。
版权声明:本文为shuai370982原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。