友盟组播推送,个人理解 只是工作用到了,所以分享一下,如果有什么不对的地方,请嘴下留情 谢谢;
其余广播,或者自定义标签都在我压缩的zip包中.
推送代码如下(组播):
/** * [友盟推送] -- 安卓组播 * appkey : "配置项" * appMasterSecret: "配置项" * type: "组播的通知条件(暂定为 poiId)" * ticker:"通知栏提示文字" * title:"通知标题" * msg:"通知内容(暂定 "您有新订单了 请注意查收")" * * @throws Exception */ public void umSendAndroidGroupcast(String appkey, String appMasterSecret, String type, String ticker, String title, String msg) throws Exception { AndroidGroupcast groupcast = new AndroidGroupcast(appkey, appMasterSecret); org.json.JSONObject filterJson = new org.json.JSONObject(); org.json.JSONObject whereJson = new org.json.JSONObject(); JSONArray tagArray = new JSONArray(); org.json.JSONObject TestTag = new org.json.JSONObject(); TestTag.put("tag", type); tagArray.put(TestTag); whereJson.put("and", tagArray); filterJson.put("where", whereJson); logger.info("安卓组播发送json:" + filterJson.toString()); groupcast.setFilter(filterJson); groupcast.setTicker(ticker); groupcast.setTitle(title); groupcast.setText(msg); groupcast.goAppAfterOpen(); groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION); groupcast.setProductionMode(); client.send(groupcast); } /** * [友盟推送] -- IOS 组播 * appkey : "配置项" * appMasterSecret: "配置项" * msg: "组播的通知条件(暂定为 poiId)" * * @throws Exception */ public void sendIOSGroupcast(String appkey, String appMasterSecret, String type, String msg) throws Exception { IOSGroupcast groupcast = new IOSGroupcast(appkey, appMasterSecret); /* * TODO Construct the filter condition: "where": { "and": [ * {"tag":"iostest"} ] } */ JSONObject filterJson = new JSONObject(); JSONObject whereJson = new JSONObject(); JSONArray tagArray = new JSONArray(); JSONObject testTag = new JSONObject(); testTag.put("tag", type); tagArray.put(testTag); whereJson.put("and", tagArray); filterJson.put("where", whereJson); System.out.println(filterJson.toString()); // Set filter condition into rootJson groupcast.setFilter(filterJson); groupcast.setAlert(msg); groupcast.setBadge(0); groupcast.setSound("default"); // TODO 区分友盟的测试环境和 生产环境 groupcast.setProductionMode(); client.send(groupcast); }