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

为了省事,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. IDEA的Maxcomputer Studio开发

    一.安装 在IDEA中File > Settings > Plugins中Browse repositories搜索安装即可:MaxCompute Studio 二.开发UDF.UDAF. ...

  2. eclipse svn合并小结

    合并时候,当前在哪个分支上,哪个分支即为“主干” 弱化主干 分支的概念.svn原则上并没有主干 分子 主 从的概念.从一个项目衍生(分支)出来的版本,都可以是主,也可以是从. 版本之间互相合并原理 文 ...

  3. Maven项目运行Junit测试用例 出现ClassNotFound

    Maven 打包命令 clean package 会清空target下的目录 包含 test-classes 目录 这样执行junit的时候,会出现 ClassNotFound的错误 执行下面的命令即 ...

  4. IDEA报错Error:Module 'shop-common' production: java.lang.IndexOutOfBoundsException

    问题描述: 本来项目是正常的,编译.运行.启动都是OK的,但是在一次电脑重启后,出现了以上这个问题:Error:Module 'shop-common' production: java.lang.I ...

  5. Entity Framework Core系列之什么是Entity Framework Core

    前言 Entity Framework Core (EF Core)是微软推荐的基于.NET Core framework的应用程序数据访问技术.它是轻量级,可扩展并且支持跨平台开发.EF Core是 ...

  6. sql存储过程中使用 output、nvarchar(max)

    1.sql存储过程中使用 output CREATE PROCEDURE [dbo].[P_Max] @a int, -- 输入 @b int, -- 输入 @Returnc int output - ...

  7. H5 31-CSS元素显示模式转换

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. Codeforces Round #534 (Div. 2)D. Game with modulo-1104-D(交互+二分+构造)

    D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. 蒲公英App开发之检测新版本

    https://www.jianshu.com/p/2d3f048511d7 2017.04.17 16:22* 字数 62 阅读 422评论 0喜欢 1 可以在App内部实现检测版本更新并实现安装. ...

  10. MyBatis模糊查询不报错但查不出数据的一种解决方案

    今天在用MyBatis写一个模糊查询的时候,程序没有报错,但查不出来数据,随即做了一个测试,部分代码如下: @Test public void findByNameTest() throws IOEx ...