仔细阅读文档,下边的都是废话。

为了省事,iOS和Android 提供了所有了参数,需要那个了修改传参。

//ios  actionURL为自定义参数

           $.ajax({
type : "POST",
url:_basePath + "/------.html",
data:{"testing":"1","type":"groupcast","title":"推送标题","subtitle":"","body":"推送内容"
,"description":"","actionURL":""
,"device_tokens":"","app_version":"","launch_from":"","not_launch_from":"","alias_type":"","alias":"","tag":""
,"badge":"","sound":"","available":"","category":""
,"policy":"","start_time":"","expire_time":""},
dataType : "JSON",
success : function(res) {
alert(res);
} }); //Android go_custom 可以设置自定义参数,没有参数打不开app,只想打开app 只能用go_app
$.ajax({
type : "POST",
url:_basePath + "/-------.html",
dataType : "JSON",
data:{"testing":"1","type":"groupcast","ticker":"tuisong","title":"挑剔","text":"内容","description":""
,"after_open": "go_custom", "url":"https://www.baidu.com","activity":"","custom":"","device_tokens":""
,"app_version":"","alias_type":"","alias":"","tag":"北京市北京市海淀区"
,"policy":"","start_time":"","expire_time":"","out_biz_no":"","launch_from":"","not_launch_from":""
,"sound":"","play_vibrate":"","play_lights":"","play_sound":""},
success : function(res) {
alert(res);
} }); }

JS提交参数

java 后台签名上传

//MD5
private String md5(String value){
String result = null;
MessageDigest md5 = null;
try{
md5 = MessageDigest.getInstance("MD5");
md5.update((value).getBytes("UTF-8"));
}catch (NoSuchAlgorithmException error){
error.printStackTrace();
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
byte b[] = md5.digest();
int i;
StringBuffer buf = new StringBuffer(""); for(int offset=0; offset<b.length; offset++){
i = b[offset];
if(i<0){
i+=256;
}
if(i<16){
buf.append("0");
}
buf.append(Integer.toHexString(i));
} result = buf.toString();
return result;
}

java md5签名

后台参数操作

        // 发送推送 iOS
@RequestMapping("/=-------------OS")
public void coreManagementsendPushiOS(HttpServletRequest request, HttpServletResponse response) throws Exception { DefaultValidate validate = new DefaultValidate();
Map<String, Object> params = read(request, validate); HashMap<String, Object> aps = new HashMap<>();
HashMap<String, Object> payload = new HashMap<>();
HashMap<String, Object> md5s = new HashMap<>(); HashMap<String, Object> alert = new HashMap<>();
//主标题
if(params.get("title").toString().length()>0) {
alert.put("title", params.get("title"));
}
//副标题
if(params.get("subtitle").toString().length()>0) {
alert.put("subtitle", params.get("subtitle"));
}
//内容
if(params.get("body").toString().length()>0) {
alert.put("body", params.get("body"));
}
aps.put("alert",alert); md5s.put("appkey", "-------");
md5s.put("timestamp", System.currentTimeMillis()); //0正式 1测试 if(params.get("testing").toString().length()>0) {
if("1".equals(params.get("testing"))) {
md5s.put("production_mode", false);
}
}
//判断加入 //发送类型 单播广播等
if("unicast".equals(params.get("type"))) {
md5s.put("device_tokens", params.get("device_tokens"));
} //列表播 英文,隔开,不超500
else if("listcast".equals(params.get("type"))) {
md5s.put("device_tokens", params.get("device_tokens"));
}//groupcast组播 按照filter条件筛选特定用户群, 具体请参照filter参数
else if("groupcast".equals(params.get("type"))) { // 多个标签 安定 or 标签
HashMap<String, Object> where = new HashMap<>();
List<Map<String, Object>> and =new ArrayList<>(); HashMap<String, Object> filter = new HashMap<>(); //应用版本
if(params.get("app_version").toString().length()>0) {
HashMap<String, Object> app_version = new HashMap<>();
app_version.put("app_version", params.get("app_version"));
and.add(app_version); } //一段时间呢你活跃
if(params.get("launch_from").toString().length()>0) {
HashMap<String, Object> launch_from = new HashMap<>();
launch_from.put("launch_from", params.get("launch_from"));
and.add(launch_from);
} //一段时间内不活跃活跃
if(params.get("not_launch_from").toString().length()>0) {
HashMap<String, Object> not_launch_from = new HashMap<>();
not_launch_from.put("not_launch_from", params.get("not_launch_from"));
and.add(not_launch_from);
} //别名
if(params.get("tag").toString().length()>0) {
HashMap<String, Object> tag = new HashMap<>();
tag.put("tag", params.get("tag"));
and.add(tag);
} where.put("and", and);
filter.put("where", where);
md5s.put("filter", filter);
}//按照filter条件筛选特定用户群, 具体请参照filter参数
else if("customizedcast".equals(params.get("type"))) { //别名
if(params.get("alias_type").toString().length()>0) {
md5s.put("alias_type", params.get("alias_type"));
} if(params.get("alias").toString().length()>0) {
md5s.put("alias", params.get("alias"));
} } //aps
if(params.get("badge").toString().length()>0) {
aps.put("badge", params.get("badge"));
}
if(params.get("sound").toString().length()>0) {
aps.put("sound", params.get("sound"));
} if(params.get("category").toString().length()>0) {
aps.put("category", params.get("category"));
} //自定义内容 payload里边 actionURL:url
if(params.get("actionURL").toString().length()>0) {
payload.put("actionURL", params.get("actionURL"));
} //发送策略
if(params.get("policy").toString().length()>0) { HashMap<String, Object> policy = new HashMap<>(); //定时发送
if(params.get("start_time").toString().length()>0) {
policy.put("start_time", params.get("start_time"));
} //过期时间
if(params.get("expire_time").toString().length()>0) {
policy.put("expire_time", params.get("expire_time"));
} md5s.put("policy", policy);
} //消息描述
if(params.get("description").toString().length()>0) {
md5s.put("description", params.get("description"));
} payload.put("aps", aps);
md5s.put("type", params.get("type"));
md5s.put("payload", payload); String url = "http://msg.umeng.com/api/send?sign="+this.md5("POST"+"http://msg.umeng.com/api/send"+JsonUtils.parseObjectToJson(md5s)+"------你的App Master Secret------");
String message = "";
try {
message = HttpClientUtil.doPostJsonAuth(url, JsonUtils.parseObjectToJson(md5s));
} catch (Exception e) {
e.printStackTrace();
message = e.getMessage();
}
write(response,message);
}

iOS

// 发送推送 Android
@RequestMapping("------------")
public void core-----Push(HttpServletRequest request, HttpServletResponse response) throws Exception { DefaultValidate validate = new DefaultValidate();
Map<String, Object> params = read(request, validate); HashMap<String, Object> body = new HashMap<>();
HashMap<String, Object> payload = new HashMap<>();
HashMap<String, Object> md5s = new HashMap<>();
HashMap<String, Object> extra = new HashMap<>(); body.put("ticker",params.get("ticker"));
body.put("title",params.get("title"));
body.put("text",params.get("text"));
body.put("after_open",params.get("after_open")); payload.put("display_type","notification"); //0正式 1测试
if(params.get("testing").toString().length()>0) {
if("1".equals(params.get("testing"))) {
md5s.put("production_mode", false);
}
} //extra 自定义参数
extra.put("url", params.get("url")); //打开应用行为
if("go_url".equals(params.get("after_open"))) {
body.put("url",params.get("url"));
} //特定行为
else if("go_activity".equals(params.get("after_open"))) {
body.put("activity",params.get("activity"));
}
//用户自定义
else if("go_custom".equals(params.get("after_open"))) {
body.put("custom",params.get("custom"));
} //发送策略
if(params.get("policy").toString().length()>0) { HashMap<String, Object> policy = new HashMap<>(); //定时发送
if(params.get("start_time").toString().length()>0) {
policy.put("start_time", params.get("start_time"));
} //过期时间
if(params.get("expire_time").toString().length()>0) {
policy.put("expire_time", params.get("expire_time"));
}
//消息标识
if(params.get("out_biz_no").toString().length()>0) {
policy.put("out_biz_no", params.get("out_biz_no"));
} md5s.put("policy", policy);
} //判断加入 //发送类型 单播广播等
if("unicast".equals(params.get("type"))) {
md5s.put("device_tokens", params.get("device_tokens"));
} //列表播 英文,隔开,不超500
else if("listcast".equals(params.get("type"))) {
md5s.put("device_tokens", params.get("device_tokens"));
}//按照filter条件筛选特定用户群, 具体请参照filter参数
else if("groupcast".equals(params.get("type"))) { // 多个标签 安定 or 标签
HashMap<String, Object> where = new HashMap<>();
List<Map<String, Object>> and =new ArrayList<>();
HashMap<String, Object> filter = new HashMap<>(); //应用版本
if(params.get("app_version").toString().length()>0) {
HashMap<String, Object> app_version = new HashMap<>();
app_version.put("app_version", params.get("app_version"));
and.add(app_version); } //一段时间呢你活跃
if(params.get("launch_from").toString().length()>0) {
HashMap<String, Object> launch_from = new HashMap<>();
launch_from.put("launch_from", params.get("launch_from"));
and.add(launch_from);
} //一段时间内不活跃活跃
if(params.get("not_launch_from").toString().length()>0) {
HashMap<String, Object> not_launch_from = new HashMap<>();
not_launch_from.put("not_launch_from", params.get("not_launch_from"));
and.add(not_launch_from);
} //别名
if(params.get("tag").toString().length()>0) {
HashMap<String, Object> tag = new HashMap<>();
tag.put("tag", params.get("tag"));
and.add(tag);
} where.put("and", and);
filter.put("where", where);
md5s.put("filter", filter); }//按照filter条件筛选特定用户群, 具体请参照filter参数
else if("customizedcast".equals(params.get("type"))) { //别名
if(params.get("alias_type").toString().length()>0) {
md5s.put("alias_type", params.get("alias_type"));
} if(params.get("alias").toString().length()>0) {
md5s.put("alias", params.get("alias"));
}
//需要调用sdk
} //sound
if(params.get("sound").toString().length()>0) {
md5s.put("sound", params.get("sound"));
} //是否震动
if(params.get("play_vibrate").toString().length()>0) {
md5s.put("play_vibrate", params.get("play_vibrate"));
} //是否闪灯
if(params.get("play_lights").toString().length()>0) {
md5s.put("play_lights", params.get("play_lights"));
} //是否发出声音
if(params.get("play_sound").toString().length()>0) {
md5s.put("play_sound", params.get("play_sound"));
} //消息描述
if(params.get("description").toString().length()>0) {
md5s.put("description", params.get("description"));
} payload.put("extra", extra);
payload.put("body", body);
md5s.put("appkey", "----------");
md5s.put("timestamp", System.currentTimeMillis());
md5s.put("type", params.get("type"));
md5s.put("payload", payload); String url = "http://msg.umeng.com/api/send?sign="+this.md5("POST"+"http://msg.umeng.com/api/send"+JsonUtils.parseObjectToJson(md5s)+"-------你的App Master Secret---");
String message = "";
try {
message = HttpClientUtil.doPostJson(url, JsonUtils.parseObjectToJson(md5s));
} catch (Exception e) {
e.printStackTrace();
message = e.getMessage();
}
write(response,message);
}

Android

想区分什么类型在app上传什么样的字段,通过tag设置更准确的发送通知

需要注意的是,Android 的 after_open 设置为go_custom ,可以设置自定义参数,没有参数打不开app,只想打开app 只能用go_app


JAVA web 使用有盟推送总结的更多相关文章

  1. java 集成友盟推送

    原文:https://blog.csdn.net/Athena072213/article/details/83414743 最近应公司业务需求需要完善友盟推送,认真看了官方文档后其实很简单,只需要细 ...

  2. 友盟推送 .NET (C#) 服务端 SDK rest api 调用库

    友盟推送 .NET SDK rest api 介绍 该版本是基于友盟推送2.3版本封装的,网上查询了下发现没有.NET版本的调用库,官方也没有封装.NET的版本,只有python.java.php版本 ...

  3. 极光推送和友盟推送,ios端和安卓端的后端调试设置

    我是最后端的,这两天搞了一个app项目,前端安卓使用友盟很方便,调试比较顺利,然后ios就遇到各种问题了,证书.发送成功推送不成功,测试时用的TestMode(),ios上架之后就必须用product ...

  4. IOS----友盟推送详解

    这两天好好的研究了下推送这功能,关于它我将分成两部分来讲,一.IOS手机端,二.Servlet服务端,今天先讲下IOS端 一.感受 下面讲下我对推送这个功能在IOS下的感受,这个算是我做了服务端的功能 ...

  5. 使用极光/友盟推送,APP进程杀死后为什么收不到推送(转)

    为什么会存在这样的 问题,刚开始的时候我也搞不清楚,之前用极光的时候杀死程序后也会收到推送,但最近重新再去集成时就完全不好使了,这我就纳闷了,虽然Google在高版本上的android上面不建议线程守 ...

  6. 友盟推送里面的Alias怎么用?可以理解成账号吗?

    友盟推送里面的Alias怎么用?可以理解成账号吗? 我们的App有自己的账号体系的,想在每次用户登陆的时候,给用户发一个欢迎消息. 看了一下友盟推送,里面有一个概念叫做Alias(别名),但是官方文档 ...

  7. iOS app 集成友盟推送问题

    之前做app推送主要是集成友盟SDK,在程序获取deviceToken时,老是提示如下错误: Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用 ...

  8. iOS集成友盟推送

    之前有写过利用Python自己写一个推送服务器, 今天说下如果集成友盟的推送服务 在这之前我们需要做一些准备动作 #1. 注册一个App ID #2. Enable Push Notification ...

  9. AppDelegate减负之常用三方封装 - 友盟推送篇

    之前分享过集成友盟推送的方法, 需要的朋友可以查看一下链接: http://www.cnblogs.com/zhouxihi/p/6533058.html 一般开发中我们比较多使用的三方有友盟推送, ...

随机推荐

  1. object detection[NMS]

    非极大抑制,是在对象检测中用的较为频繁的方法,当在一个对象区域,框出了很多框,那么如下图: 上图来自这里 目的就是为了在这些框中找到最适合的那个框.有以下几种方式: 1 nms 2 soft-nms ...

  2. Unity热更新学习(二) —— ToLua c#与lua的相互调用

    tolua 下载地址:http://www.ulua.org/index.html c#调用lua的方法,tolua的官方例子提供了很多种.我初步学了一种在做项目使用的方法.通过DoFile方法执行l ...

  3. FineUIMvc随笔(7)扩展通知对话框(显示多个不重叠)

    声明:FineUIMvc(基础版)是免费软件,本系列文章适用于基础版. 这篇文章我们将改造 FineUIMvc 默认的通知对话框,使得同时显示多个也不会重叠.并提前出一个公共的JS文件,供大家使用. ...

  4. Ubuntu: 软件库(software repositories)

    Linux 生态下,几乎每个发行版都有自己的软件库(software repositories),Ubuntu 当然也不例外.Ubuntu 提供了四个不同的软件库,分别是 main.restricte ...

  5. 第十二次oo作业

    作业十二 规格化设计简介 规格化设计的发展历史 1950年代,第一次分离,主程序与子程序的分离结构是树状模型,子程序可先于主程序编写.通过使用库函数来简化编程,实现最初的代码重用.产生基本的软件开发过 ...

  6. poj2594 机器人寻找宝藏(最小路径覆盖)

    题目来源:http://poj.org/problem?id=2594 参考博客:http://www.cnblogs.com/ka200812/archive/2011/07/31/2122641. ...

  7. UnderWater+SDN论文之六

    Protocol Emulation Platform Based on Microservice Architecture for Underwater Acoustic Networks Sour ...

  8. 2017软工实践K班总结

    回首一学期的软工实践,从暑假开始陆续布置作业,经历个人.结对与团队等大小作业.也经历了不少同学被吓跑.第一周就退选的情况,能坚持下来的都是胜利者,至少你们有一颗愿意挑战的心.首先感谢助教谢涛付出的巨大 ...

  9. JEECG 3.7 Memory Leak

    JEECG 3.7 版本常见问题贴 - JEECG官方网站-企业级JAVA快速开发平台 - Powered by Discuz!http://www.jeecg.org/forum.php?mod=v ...

  10. 移动端tap事件,消除300毫秒延迟

    引用这个之前,要讲一下首先我是用了webpack技术,所以你的项目如果没有用到这个的话,最好不要用这个技术,当然想用也可以,改下代码也可以用. 下面的代码直接复制就可以用啦. ( function(e ...