atitit.极光消息推送服务器端开发实现推送 jpush v3. 总结o7p
2016-01-09 22:18
501 查看
atitit.极光消息推送服务器端开发实现推送 jpush v3. 总结o7p
1. 推送所设计到底功能1
1.1. 内容压缩1
1.2. 多引擎1
2. reg ,设置appkey and pwdkey1
3. 下载server sdk v31
4. push推送样例1
5. Code3
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
// For push, all you need do is to build PushPayload object.
PushPayload payload = buildPushObject_all_all_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
// Connection error, should retry later
LOG.error("Connection error, should retry later", e);
} catch (APIRequestException e) {
// Should review the error, and fix the request
LOG.error("Should review the error, and fix the request", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
进行推送的关键在于构建一个 PushPayload 对象。以下示例一般的构建对象的用法。
private static void single_test(final double i) throws APIConnectionException,
APIRequestException {
core.execMeth_Ays(new Runnable() {
@Override
public void run() {
String r = "";
try {
r = new pushX().push(".", 1099);
} catch (APIConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(String.valueOf(i) + "::" + r);
}
}, " threadName");
}
public String push(final String txt, final Object... target)
throws APIConnectionException, APIRequestException {
// attilax 老哇的爪子 X5042 o7m // k_56_44 o80 老哇的爪子 Attilax
core.log("---- o8q14 add act n seruinfo before txt:" + txt);
core.log("----add act n seruinfo before len:"
+ String.valueOf(txt.length()));
final String s = jpushCompressor.kmprs(txt);
core.log("----add act n seruinfo aft len:" + String.valueOf(s.length()));
logger.info(txt + "\r\ntarget:" + StringUtils.join(target, ",") + " ");
// new com.attilax.tryX<String>() {
// @Override public String $$(Object t) throws Exception {
// attilax 老哇的爪子 2_q_9 o86
setInvokeTimes();
try {
PushExample.SendPush_msgFmt(s, core.toStrArr(target));
} finally {
// this.respMsg=r;
this.sendMsg = PushExample.sendMsg_thrdloc.get();
}
// catch (APIConnectionException e) {
// respMsg="APIConnectionException";
// }
// catch (APIRequestException e) {
// respMsg=
// }
// return null;
// }
// }.$("");
new com.attilax.tryX<String>() {
@Override
public String $$(Object t) throws Exception {
// attilax 老哇的爪子 2_q_9 o86
// PushExample.SendPush(s, core.toStrArr(target));
return null;
}
}.$("");
String r = PushExample.rzt.get();
return r;
}
1. 推送所设计到底功能1
1.1. 内容压缩1
1.2. 多引擎1
2. reg ,设置appkey and pwdkey1
3. 下载server sdk v31
4. push推送样例1
5. Code3
1. 推送所设计到底功能
1.1. 内容压缩
1.2. 多引擎
2. reg ,设置appkey and pwdkey
3. 下载server sdk v3
https://github.com/jpush/jpush-api-java-client作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
4. push推送样例
以下片断来自项目代码里的文件:cn.jpush.api.examples.PushExampleJPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
// For push, all you need do is to build PushPayload object.
PushPayload payload = buildPushObject_all_all_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
// Connection error, should retry later
LOG.error("Connection error, should retry later", e);
} catch (APIRequestException e) {
// Should review the error, and fix the request
LOG.error("Should review the error, and fix the request", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
进行推送的关键在于构建一个 PushPayload 对象。以下示例一般的构建对象的用法。
5. Code
Pushx。Javaprivate static void single_test(final double i) throws APIConnectionException,
APIRequestException {
core.execMeth_Ays(new Runnable() {
@Override
public void run() {
String r = "";
try {
r = new pushX().push(".", 1099);
} catch (APIConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(String.valueOf(i) + "::" + r);
}
}, " threadName");
}
public String push(final String txt, final Object... target)
throws APIConnectionException, APIRequestException {
// attilax 老哇的爪子 X5042 o7m // k_56_44 o80 老哇的爪子 Attilax
core.log("---- o8q14 add act n seruinfo before txt:" + txt);
core.log("----add act n seruinfo before len:"
+ String.valueOf(txt.length()));
final String s = jpushCompressor.kmprs(txt);
core.log("----add act n seruinfo aft len:" + String.valueOf(s.length()));
logger.info(txt + "\r\ntarget:" + StringUtils.join(target, ",") + " ");
// new com.attilax.tryX<String>() {
// @Override public String $$(Object t) throws Exception {
// attilax 老哇的爪子 2_q_9 o86
setInvokeTimes();
try {
PushExample.SendPush_msgFmt(s, core.toStrArr(target));
} finally {
// this.respMsg=r;
this.sendMsg = PushExample.sendMsg_thrdloc.get();
}
// catch (APIConnectionException e) {
// respMsg="APIConnectionException";
// }
// catch (APIRequestException e) {
// respMsg=
// }
// return null;
// }
// }.$("");
new com.attilax.tryX<String>() {
@Override
public String $$(Object t) throws Exception {
// attilax 老哇的爪子 2_q_9 o86
// PushExample.SendPush(s, core.toStrArr(target));
return null;
}
}.$("");
String r = PushExample.rzt.get();
return r;
}
相关文章推荐
- 关于串口与单片机通信电平转换的总结
- Java类成员(成员变量和方法)的覆盖与隐藏归纳
- 注册表自启动问题
- CATransform3D的m34值动画
- DRUID连接池的简单使用
- java构造函数是否可继承,以及子类构造函数可否不使用super调用超类构造函数
- Codeforces Round #338 (Div. 2) B. Longtail Hedgehog(LIS)
- swift入门———数组
- atitit.极光消息推送服务器端开发实现推送 jpush v3. 总结o7p
- Angular数据双向绑定
- 服了这个所谓北大青鸟官方学员社区论坛
- 概率算法
- 算法基础训练(二)
- Python多进程编程
- Spark Streaming:TCP(基本类型)数据源
- 数据结构学习笔记——顺序表和链表的比较
- excel中画坐标轴的备用知识
- 快播案乐视被网友吊打 贾跃亭微博喊冤
- 到底应不应该上培训班
- hdu 2066 一个人的旅行(加超级源点)