JAVA 友盟后台推送 包含安卓/IOS,以及代码zip

5 篇文章 0 订阅
4 篇文章 0 订阅

友盟组播推送,个人理解 只是工作用到了,所以分享一下,如果有什么不对的地方,请嘴下留情 谢谢;

其余广播,或者自定义标签都在我压缩的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);
 }

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值