package push;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.commons.codec.digest.DigestUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import push.android.AndroidBroadcast;
import push.android.AndroidCustomizedcast;
import push.android.AndroidFilecast;
import push.android.AndroidGroupcast;
import push.android.AndroidUnicast;
import push.ios.IOSBroadcast;
import push.ios.IOSCustomizedcast;
import push.ios.IOSFilecast;
import push.ios.IOSGroupcast;
import push.ios.IOSUnicast;
public class Demo {
private String appkey = null;
private String appMasterSecret = null;
private String timestamp = null;
private PushClient client = new PushClient();
public Demo(String key, String secret) {
try {
appkey = key;
appMasterSecret = secret;
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public void sendAndroidBroadcast() throws Exception {
AndroidBroadcast broadcast = new AndroidBroadcast(appkey,appMasterSecret);
broadcast.setTicker( "Android broadcast ticker");
broadcast.setTitle( "中文的title");
broadcast.setText( "Android broadcast text");
broadcast.goAppAfterOpen();
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// TODO Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
broadcast.setProductionMode();
// Set customized fields
broadcast.setExtraField("test", "helloworld");
client.send(broadcast);
}
public void sendAndroidUnicast() throws Exception {
AndroidUnicast unicast = new AndroidUnicast(appkey,appMasterSecret);
// TODO Set your device token
unicast.setDeviceToken( "your device token");
unicast.setTicker( "Android unicast ticker");
unicast.setTitle( "中文的title");
unicast.setText( "Android unicast text");
unicast.goAppAfterOpen();
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// TODO Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
unicast.setProductionMode();
// Set customized fields
unicast.setExtraField("test", "helloworld");
client.send(unicast);
}
public void sendAndroidGroupcast() throws Exception {
AndroidGroupcast groupcast = new AndroidGroupcast(appkey,appMasterSecret);
/* TODO
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"test"},
* {"tag":"Test"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
JSONObject TestTag = new JSONObject();
testTag.put("tag", "test");
TestTag.put("tag", "Test");
tagArray.put(testTag);
tagArray.put(TestTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
System.out.println(filterJson.toString());
groupcast.setFilter(filterJson);
groupcast.setTicker( "Android groupcast ticker");
groupcast.setTitle( "中文的title");
groupcast.setText( "Android groupcast text");
groupcast.goAppAfterOpen();
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// TODO Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
groupcast.setProductionMode();
client.send(groupcast);
}
public void sendAndroidCustomizedcast() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
// TODO Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
customizedcast.setTicker( "Android customizedcast ticker");
customizedcast.setTitle( "中文的title");
customizedcast.setText( "Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// TODO Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
client.send(customizedcast);
}
public void sendAndroidCustomizedcastFile() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey,appMasterSecret);
// TODO Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb"+"\n"+"alias");
customizedcast.setFileId(fileId, "alias_type");
customizedcast.setTicker( "Android customizedcast ticker");
customizedcast.setTitle( "中文的title");
customizedcast.setText( "Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// TODO Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
client.send(customizedcast);
}
public void sendAndroidFilecast() throws Exception {
AndroidFilecast filecast = new AndroidFilecast(appkey,appMasterSecret);
// TODO upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey,appMasterSecret,"aa"+"\n"+"bb");
filecast.setFileId( fileId);
filecast.setTicker( "Android filecast ticker");
filecast.setTitle( "中文的title");
filecast.setText( "Android filecast text");
filecast.goAppAfterOpen();
filecast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
client.send(filecast);
}
public void sendIOSBroadcast() throws Exception {
IOSBroadcast broadcast = new IOSBroadcast(appkey,appMasterSecret);
broadcast.setAlert("IOS 广播测试");
broadcast.setBadge( 0);
broadcast.setSound( "default");
// TODO set 'production_mode' to 'true' if your app is under production mode
broadcast.setTestMode();
// Set customized fields
broadcast.setCustomizedField("test", "helloworld");
client.send(broadcast);
}
public void sendIOSUnicast() throws Exception {
IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
// TODO Set your device token
unicast.setDeviceToken( "xx");
unicast.setAlert("IOS 单播测试");
unicast.setBadge( 0);
unicast.setSound( "default");
// TODO set 'production_mode' to 'true' if your app is under production mode
unicast.setTestMode();
// Set customized fields
unicast.setCustomizedField("test", "helloworld");
client.send(unicast);
}
public void sendIOSGroupcast() 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", "iostest");
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("IOS 组播测试");
groupcast.setBadge( 0);
groupcast.setSound( "default");
// TODO set 'production_mode' to 'true' if your app is under production mode
groupcast.setTestMode();
client.send(groupcast);
}
public void sendIOSCustomizedcast() thro
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
youmeng.zip (49个子文件)
youmeng
.project 533B
src
main
java
push
ios
IOSBroadcast.java 324B
IOSGroupcast.java 465B
IOSCustomizedcast.java 913B
IOSFilecast.java 706B
IOSUnicast.java 435B
AndroidNotification.java 7KB
UmengNotification.java 3KB
Demo.java 10KB
android
AndroidUnicast.java 456B
AndroidFilecast.java 725B
AndroidBroadcast.java 341B
AndroidGroupcast.java 485B
AndroidCustomizedcast.java 942B
IOSNotification.java 3KB
PushClient.java 4KB
target
push-0.0.1-SNAPSHOT.jar 21KB
maven-status
maven-compiler-plugin
compile
default-compile
createdFiles.lst 0B
inputFiles.lst 1KB
generated-sources
annotations
classes
META-INF
MANIFEST.MF 105B
maven
com.umeng.message
push
pom.properties 215B
pom.xml 688B
push
PushClient.class 5KB
AndroidNotification$DisplayType.class 1KB
AndroidNotification.class 6KB
AndroidNotification$DisplayType$1.class 647B
ios
IOSCustomizedcast.class 964B
IOSFilecast.class 757B
IOSGroupcast.class 802B
IOSUnicast.class 763B
IOSBroadcast.class 638B
Demo.class 7KB
android
AndroidGroupcast.class 826B
AndroidFilecast.class 781B
AndroidUnicast.class 787B
AndroidCustomizedcast.class 988B
AndroidBroadcast.class 662B
IOSNotification.class 3KB
AndroidNotification$AfterOpenAction.class 1KB
UmengNotification.class 3KB
AndroidNotification$DisplayType$2.class 642B
maven-archiver
pom.properties 115B
test-classes
.settings
org.eclipse.m2e.core.prefs 86B
org.eclipse.jdt.core.prefs 238B
pom.xml 688B
release-notes 227B
.classpath 996B
.gitignore 39B
README 660B
共 49 条
- 1
资源评论
- jiandango2022-05-23可以借鉴参考使用
冷锋-
- 粉丝: 103
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 学院期间学习代码,包括C,Python,HTML, Java等代码.zip
- 控制原理之经典传递函数
- 全国大学生电子设计竞赛 历年赛题(1994-2023)
- Unity适用于Windows与移动平台双端的轮盘交互式提示菜单
- UE5/UE4超详细教程接入科大讯飞语音唤醒SDK并初始持久监听(10102错误码解决)
- 靠搬运古装剧解说视频,日收益200+,作品原创度90%以上,超详细教程-教程网盘链接提取码下载 .txt
- 2024最强数学建模之美赛攻略.md
- STM32单片机FPGA毕设电路原理论文报告一种机器人寻线控制系统
- STM32单片机FPGA毕设电路原理论文报告一种光电编码器位置检测系统研究与应用
- linux常用命令大全
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功