ixintui服务端SDK(java版)
详细文档请移步REST_API_V2.md
sdk包目录结构
ixintuiPush REST API 的 Java 版本封装开发包,是由爱心推官方提供:
- \jar下为集成所需jar包。
- \document下为开发文档。
- \demo下有两个demo:
1> TestJavaPush:Test.java为集成ixintui_server_push_sdk.jar的示例demo,开发过程中可以参考。
2> javapush:可以直接双击运行java_push.bat并输入对应指令查看示例结果,result为0表示推送成功。
使用说明
说明:sdk使用jdk1.6编译,如有问题请使用jdk1.6编译使用。
1 添加jar包依赖
将jar目录下的 和 复制到项目里,并添加依赖。
2 开发流程
new一个Message对象,设置相关属性,然后调用message.sendPush()方法,可以参考demo\TestJavaPush\Test.java。
3 Message对象
Message对象包含12种类型的消息:
含义 | 对应Message | 备注 |
---|---|---|
全部用户 | SendAllMessage | |
全部android用户 | SendAndroidMessage | |
全部IOS用户 | SendIosMessage | 指定别名发送 |
指定别名发送,只给别名对应的最后活跃的1个设备发送 | SendLastAliasMessage | 必须传参:别名 类型: |
指定别名发送,给别名对应的所有设备发送 | SendAliasMessage | 必须传参:别名 |
指定token发送 | SendTokenMessage | 必须传参:token |
按tag/not_tag过滤 | SendTagMessage | 必须传参:tag/not_tag |
按stag/not_stag过滤 | SendStagMessage | 必须传参:stag/not_stag |
按用户信息过滤 | SendOptfilterMessage | 必须传参:Optfilter(见4-f);目前仅支持android |
指定tag/not_tag及用户信息 | SendTagAndOptfilterMessage | 必须传参:Optfilter(见4-f)和tag/not_tag;目前仅支持android |
指定stag/not_stag及用户信息 | SendStagAndOptfilterMessage | 必须传参:Optfilter(见4-f)和stag/not_stag;目前仅支持android |
stringTag添加、删除、查询接口 | StagsMessage |
4 属性设置
透传消息说明: 对于ios,透传消息的内容需要设置extra, 同时需要设置extra字段才能传输内容,content将被忽略。对于android用户来说,透传消息的设置和通知都需要设置content字段,但透传消息的extra字段将被忽略。
- setIsNotify(int isNotify):0透传消息(默认),1通知消息。
- AndroidNotification:设置Android推送通知消息的样式。如果设置该属性,将默认为通知消息,可以不设置isNotify属性。包含以下参数:
参数 | 参数含义 | 参数类型 | 默认值 |
---|---|---|---|
sound | false:无声音,true:有声音 | boolean | false |
unremovable | false:不可移除,true:可移除 | boolean | false |
title | 消息标题 | string | App名字 |
click_action | 0:无动作,1:打开App,2:打开网页3:打开intent;参数用click_param设置 | int | 无动作 |
click_param | url地址或intent | string | 当click_action 存在时,必须字段 |
vibrate | false:不振动 true:震动 | boolean | 当click_action 存在时,必须字段 |
badge | 角标显示数字 | int | 默认无,不改变原有角标,-1代表自增 |
message.setAndroidNotification(new AndroidNotification(true, false, "ixintui Push", 1, "", true, 0));
- IosNotification:设置Ios推送通知消息的样式。如果设置该属性,将默认为通知消息,可以不设置isNotify属性。包含以下参数:
参数 | 参数含义 | 参数类型 | 默认值 |
---|---|---|---|
badge | 角标显示数字 | int | 默认无,不改变原有脚本,-1代表自增 |
sound | 声音文件名 | string | 默认为default |
content-available | 0:不触发background mode,1: 触发background mode | int | 无默认 |
category | 从IOS8支持,自定义动作设置 | string | 无默认 |
message.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category").setContent_available(1).setSound("default"));
Platform:设置发送平台(除SendAllMessage、SendAndroidMessage、SendIosMessage),给设置的平台推送消息,一个也不设置发送不成功。
AndroidPlatform
message.setAndroidPlatform(androidAppKey, androidSecretkey);
- iOSPlatform
message.setIosPlatform(iosAppKey, iosSecretkey);
- Option(非必须属性):可以设置每条消息的选项。包含以下参数:
参数 | 参数含义 | 参数类型 | 默认值 |
---|---|---|---|
period | 消息存活周期,单位秒 | int | 在创建应用时指定 |
qps | 发送速度,单位 个/秒,默认为0,代表以最大速度发送 | int | 默认为0,代表以最大速度发送 |
timed | 定时消息,默认0 | int | 0:非定时消息,默认值; 1:按具体时间点定时,用send_time参数来指定具体时间点; 2:按时间间隔定时,用send_time_interval参数指定时间间隔 |
send_time | 定时消息具体发送时间点 | string | timed为1时生效, 格式Y-%m-%d %H:%M (for example 2014-09-01 5:30) |
send_time_interval | 定时消息的时间间隔 | int | timed为2时生效,单位秒 |
message.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(0));
- Optfilter(非必须属性):推送消息按用户信息过滤。
参数名字 | 类型 | 描述 |
---|---|---|
locate | List列表 | 地域选项,取值见附录 |
osversion | List列表 | 操作系统选项 |
appversion | List列表 | 应用的版本选项 |
channel | List列表 | 应用的渠道选项 |
phone | List列表 | 手机品牌选项 |
operator | List列表 | 运营商选项,取值见附录 |
activity_1 | Map集合 | 1天内应用打开次数选项,key:>, <, >=, <=, = |
activity_7 | Map集合 | 7天内应用打开次数选项,key:>, <, >=, <=, = |
activity_30 | Map集合 | 30天内应用打开次数选项,key:>, <, >=, <=, = |
activity_90 | Map集合 | 90天内应用打开次数选项,key:>, <, >=, <=, = |
List<String> locate8 = new ArrayList<>();
locate8.add("北京市");
Map<String, Integer> activity_30 = new HashMap<>();
activity_30.put("<", 20);
Optfilter optfilter8 = Optfilter.getInstance().setLocate(locate8).setActivity_30(activity_30);
5 Test.java
以下是Test.java中的部分代码,具体可参考demo\TestJavaPush\Test.java:
switch (type) {
case 0:
try {
json1.put("body", "this is content.");
json1.put("title", "this is title.");
json2.put("ios", json1);
json2.put("android", "this is a all push message android.");
} catch (JSONException e1) {
e1.printStackTrace();
}
/**
* 给指定App所有的Android和Ios客户端推送通知消息
* new一个SendAllMessage对象,传入Android和Ios的Appkey和Secretkey,并指定消息内容,消息内容若为string则iOS无title显示,若要添加iOS的title可如上述JSONObject写法
*/
SendAllMessage sendAllMessage = new SendAllMessage(json2.toString(), androidAppKey,
androidSecretkey, iosAppKey, iosSecretkey);
/**
* 默认为0:透传消息,1:通知消息, 当设置AndroidNotification或IosNotification时即为通知消息,
* 可以省略该属性
*/
// sendAllMessage.setIsNotify(1);
/**
* 非必须,详细参见开发文档,设置Android通知消息的内容及样式,传入AndroidNotification
*/
sendAllMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
/**
* 非必须,详细参见开发文档,设置Android通知消息的内容及样式,传入IosNotification
*/
// sendAllMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/**
* 非必须,详细参见开发文档,设置消息选项,传入Option
*/
sendAllMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(0));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setType(Proxy.Type.HTTP);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// sendAllMessage.setProxyInfo(proxyInfo);
result = sendAllMessage.sendPush();
break;
case 1:
/**
* new一个SendAndroidMessage对象,传入Android的Appkey和Secretkey,并指定消息内容
*/
SendAndroidMessage sendAndroidMessage = new SendAndroidMessage("this is a android push message.",
androidAppKey, androidSecretkey);
sendAndroidMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// sendAndroidMessage.setProxyInfo(proxyInfo);
result = sendAndroidMessage.sendPush();
break;
case 2:
try {
json1.put("body", "this is content.");
json1.put("title", "this is title.");
json2.put("ios", json1);
} catch (JSONException e1) {
e1.printStackTrace();
}
/**
* new一个SendIosMessage对象,传入Ios的Appkey和Secretkey,并指定消息内容,若无须title可直接传string串
*/
// SendIosMessage sendIosMessage = new SendIosMessage(json2.toString(), iosAppKey, iosSecretkey);
SendIosMessage sendIosMessage = new SendIosMessage("ios test no title", iosAppKey, iosSecretkey);
// sendIosMessage.setIsNotify(1);
sendIosMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category")
.setContent_available(1).setSound("default"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// sendIosMessage.setProxyInfo(proxyInfo);
result = sendIosMessage.sendPush();
break;
case 3:
/**
* 别名集合
*/
List<String> aliasList = new ArrayList<String>();
aliasList.add("melon");
aliasList.add("dong");
try {
json1.put("body", "this is content.");
json1.put("title", "this is title.");
json2.put("ios", json1);
} catch (JSONException e1) {
e1.printStackTrace();
}
/**
* new一个SendLastAliasMessage对象, 传入消息内容和别名,别名可传一个String字符串或者List集合
*/
// SendLastAliasMessage lastAliasMessage = new
// SendLastAliasMessage("this is a last alias push message.",
// "burke");
SendLastAliasMessage lastAliasMessage = new SendLastAliasMessage("this is a specifies last active alias.",
aliasList);
/**
* 给Android用户推送消息,传入Android的AppKey和Secretkey
*/
lastAliasMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
/**
* 给iOS用户推送消息,传入Ios的AppKey和Secretkey
*/
lastAliasMessage.setIosPlatform(iosAppKey, iosSecretkey);
lastAliasMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
lastAliasMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// lastAliasMessage.setProxyInfo(proxyInfo);
result = lastAliasMessage.sendPush();
break;
case 4:
/**
* new一个SendLastAliasMessage对象, 传入消息内容和别名,别名可传一个String字符串或者List集合
*/
List<String> aliasList1 = new ArrayList<String>();
aliasList1.add("melon");
aliasList1.add("dong");
try {
json1.put("body", "this is content.");
json1.put("title", "this is title.");
json2.put("ios", json1);
json2.put("android", "this is a all push message3.");
} catch (JSONException e1) {
e1.printStackTrace();
}
// SendAliasMessage aliasMessage = new SendAliasMessage("this is a specifies alias push message78.", "melon");
SendAliasMessage aliasMessage = new SendAliasMessage(json2.toString(), aliasList1);
aliasMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
aliasMessage.setIosPlatform(iosAppKey, iosSecretkey);
aliasMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(8));
aliasMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// aliasMessage.setProxyInfo(proxyInfo);
result = aliasMessage.sendPush();
break;
case 5:
/**
* token集合
*/
List<String> tokenList = new ArrayList<String>();
tokenList.add(token1);
tokenList.add(token2);
/**
* new一个SendTokenMessage对象,传入消息内容
*/
SendTokenMessage tokenMessage = new SendTokenMessage("this is a specifies token push message.");
/**
* 给Android用户推送消息,传入Android的AppKey和Secretkey,以及token字符串或者token集合
*/
tokenMessage.setAndroidPlatform(androidAppKey, androidSecretkey, tokenList);
/**
* 给Android用户推送消息,传入Ios的AppKey和Secretkey,以及token字符串或者token集合
*/
tokenMessage.setIosPlatform(iosAppKey, iosSecretkey, token3);
tokenMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tokenMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tokenMessage.setProxyInfo(proxyInfo);
result = tokenMessage.sendPush();
break;
case 6:
/**
* tag数组集合
*/
tagsList1 = new ArrayList<int[]>();
tagsList1.add(new int[] { 1 });
tagsList1.add(new int[] { 3, 8 });
/**
* new一个SendTokenMessage对象,传入消息内容和tag,tag可以是int数字,或者int[]数组集合
*/
tagMessage = new SendTagMessage("this is a specifies tags push message.", 5);
// SendTagMessage tagMessage = new SendTagMessage("this is a last
// alias push message.", tagsList);
tagMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tagMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagMessage.setProxyInfo(proxyInfo);
result = tagMessage.sendPush();
break;
case 7:
List<String> osversion = new ArrayList<String>();
osversion.add("7.1.1");
Map<String, Integer> activity_1 = new HashMap<String, Integer>();
activity_1.put("<", 8);
/**
* 非必须,详细参见开发文档,设置消息属性
*/
Optfilter optfilter7 = Optfilter.getInstance().setOsversion(osversion).setActivity_1(activity_1);
/**
* new一个SendOptfilterMessage对象,传入消息内容和Optfilter
*/
SendOptfilterMessage optfilterMessage = new SendOptfilterMessage(
"this is a specifies optfilter push message.", optfilter7);
optfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
optfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
optfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
optfilterMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// optfilterMessage.setProxyInfo(proxyInfo);
result = optfilterMessage.sendPush();
break;
case 8:
/**
* 给指定的stagsList发,指定的not_stagsList不发
*/
optfilter = Optfilter.getInstance().setActivity_30(activity_30);
stagsList1 = new ArrayList<String[]>();
stagsList1.add(stags1);
stagsList2 = new ArrayList<String[]>();
stagsList2.add(stags2);
/**
* new一个SendStagAndOptfilterMessage对象,传入消息内容、tag和Optfilter,第一个list为stag list,第二个list为not_stag list
*/
stagAndOptfilterMessage = new SendStagAndOptfilterMessage(
"stag and not stag and optfilter push message.", stagsList1, optfilter,stagsList2);
stagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
stagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
stagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
stagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
// stagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(1).setSend_time("2018-09-30 15:30"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagAndOptfilterMessage.setProxyInfo(proxyInfo);
result = stagAndOptfilterMessage.sendPush();
break;
case 9:
/**
* 添加单个stag
*/
//map传入当前app的token值及其对应的stags
tokenTagsMap.put(token1, stags1);
tokenTagsMap3.put(token3, stags3);
//调用StagsOption函数的createDeleteSTagsOption方法,传入当前app的appKey、secretKey及其对应的tokenTagsMap
option = StagsOption.createDeleteSTagsOption(iosAppKey, iosSecretkey, tokenTagsMap3);
//new 一个List<StagsOption>对象,put进去StagsOption实例option
list.add(option);
//new 一个StagsMessage对象,传入list
stags = new StagsMessage(list);
result = stags.addStags();//添加tag
break;
case 10:
/**
* 多个app添加stag
*/
//map传入当前app的token值及其对应的stags
tokenTagsMap.put(token1, stags1);
tokenTagsMap2.put(token2, stags2);
tokenTagsMap3.put(token3, stags2);
//调用StagsOption函数的createDeleteSTagsOption方法,传入当前app的appKey、secretKey及其对应的tokenTagsMap
option = StagsOption.createDeleteSTagsOption(appKey1, secretKey1, tokenTagsMap);
option1 = StagsOption.createDeleteSTagsOption(appKey2, secretKey2, tokenTagsMap2);
//new 一个StagsOption对象,put进去StagsOption实例
list.add(option);
list.add(option1);
//new 一个StagsMessage对象,传入list
stags = new StagsMessage(list);
result = stags.addStags();//添加tag
break;
case 11:
/**
* 查询单个应用stag
*/
option = StagsOption.createQueryStagerOption(iosAppKey, iosSecretkey, tokens3);
list.add(option);
//new一个StagsMessage对象,传入上述list对象
stags = new StagsMessage(list);
result = stags.queryStags();
break;
case 12:
/**
* 查询多个应用stag
*/
option = StagsOption.createQueryStagerOption(appKey1, secretKey1, tokens1);
option1 = StagsOption.createQueryStagerOption(appKey2, secretKey2, tokens2);
option2 = StagsOption.createQueryStagerOption(iosAppKey, iosSecretkey, tokens3);
list.add(option);
list.add(option1);
list.add(option2);
//new一个StagsMessage对象,传入上述list对象
stags = new StagsMessage(list);
result = stags.queryStags();
break;
case 13:
/**
* 添加单个stag
*/
//map传入当前app的token值及其对应的stags
tokenTagsMap.put(token1, stags1);
//调用StagsOption函数的createDeleteSTagsOption方法,传入当前app的appKey、secretKey及其对应的tokenTagsMap
option = StagsOption.createDeleteSTagsOption(appKey1, secretKey1, tokenTagsMap);
//new 一个List<StagsOption>对象,put进去StagsOption实例option
list.add(option);
//new 一个StagsMessage对象,传入list
stags = new StagsMessage(list);
result = stags.deleteStags();//删除tag
break;
case 14:
/**
* 多个app删除stag
*/
//map传入当前app的token值及其对应的stags
// tokenTagsMap.put(token1, stags1);
tokenTagsMap2.put(token2, stags2);
tokenTagsMap3.put(token3, stags3);
//调用StagsOption函数的createDeleteSTagsOption方法,传入当前app的appKey、secretKey及其对应的tokenTagsMap
option = StagsOption.createDeleteSTagsOption(appKey2, secretKey2, tokenTagsMap2);
option1 = StagsOption.createDeleteSTagsOption(iosAppKey, iosSecretkey, tokenTagsMap3);
//new 一个StagsOption对象,put进去StagsOption实例
list.add(option);
list.add(option1);
//new 一个StagsMessage对象,传入list
stags = new StagsMessage(list);
result = stags.deleteStags() ;//删除tag
break;
case 15:
/**
* stag/not_stag的list集合
*/
optfilter = Optfilter.getInstance().setActivity_30(activity_30);
stagsList1 = new ArrayList<String[]>();
stagsList1.add(stags1);
stagsList1.add(stags2);
/**
* new一个SendStagAndOptfilterMessage对象,传入消息内容、tag和Optfilter,最后一个参数true表示stag,false表示not_stag
*/
stagAndOptfilterMessage = new SendStagAndOptfilterMessage(
"tags and optfilter push message.", stagsList1, optfilter,false);
stagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
stagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
stagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
stagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
stagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0));
result = stagAndOptfilterMessage.sendPush();
break;
case 16:
/**
* tag/not_tag的list集合
*/
optfilter = Optfilter.getInstance().setActivity_30(activity_30);;
tagsList1 = new ArrayList<int[]>();
tagsList1.add(tags1);
tagsList1.add(tags2);
/**
* new一个SendTagAndOptfilterMessage对象,传入消息内容、tag和Optfilter,最后一个参数true表示tag,false表示not_tag
*/
tagAndOptfilterMessage = new SendTagAndOptfilterMessage(
"tags list and optfilter push message.", tagsList1, optfilter,true);
tagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
tagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0));
result = tagAndOptfilterMessage.sendPush();
break;
case 17:
/**
* 单个的stringTag:stag
*/
optfilter = Optfilter.getInstance().setActivity_30(activity_30);
/**
* new一个SendStagAndOptfilterMessage对象,传入消息内容、stag和Optfilter,最后一个参数true表示stag,false表示not_stag
*/
stagAndOptfilterMessage = new SendStagAndOptfilterMessage(
"stag and optfilter message.", "hello", optfilter,false);
stagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
stagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
stagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
stagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
stagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0));
result = stagAndOptfilterMessage.sendPush();
break;
case 18:
/**
* 给指定的tagsList发,指定的not_tagsList不发
*/
List<String> appver1 = new ArrayList<String>();
appver1.add("1.0");
appver1.add("2.0");
// optfilter = Optfilter.getInstance();
optfilter = Optfilter.getInstance().setAppversion(appver1).setActivity_30(activity_30);
tagsList1 = new ArrayList<int[]>();
tagsList1.add(tags1);
tagsList1.add(tags3);
tagsList2 = new ArrayList<int[]>();
tagsList2.add(tags2);
/**
* new一个SendTagAndOptfilterMessage对象,传入消息内容、tag和Optfilter,第一个参数taglist表示发送的tag集合,第二个taglist表示not_tag集合
*/
tagAndOptfilterMessage = new SendTagAndOptfilterMessage(
" tag and not_tag list and optfilter push message.", tagsList1, optfilter,tagsList2);
tagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", false).setBadge(6));
tagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
// tagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(1).setSend_time("2018-10-10 15:30"));
tagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0));
result = tagAndOptfilterMessage.sendPush();
break;
case 19:
/**
* 单个的tag
*/
List<String> appver = new ArrayList<String>();
appver.add("1.0");
appver.add("2.0");
optfilter = Optfilter.getInstance().setAppversion(appver).setActivity_30(activity_30);
/**
* new一个SendTagAndOptfilterMessage对象,传入消息内容、tag和Optfilter,最后一个参数true表示tag,false表示not_tag
*/
tagAndOptfilterMessage = new SendTagAndOptfilterMessage(
"singel tag and optfilter push message.", 8, optfilter,false);
tagAndOptfilterMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagAndOptfilterMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagAndOptfilterMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tagAndOptfilterMessage
.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
// tagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(1).setSend_time("2018-10-12 15:30"));
tagAndOptfilterMessage.setOption(Option.getInstance().setPeriod(80000).setQps(0));
result = tagAndOptfilterMessage.sendPush();
break;
case 20:
/**
* 单个的tag
*/
tagsList1 = new ArrayList<int[]>();
tagsList1.add(new int[] { 1 });
tagsList1.add(new int[] { 3, 8 });
/**
* new一个SendTagMessage对象,传入消息内容和tag,tag可以是int数字,或者int[]数组集合,最后一个参数true表示是tag,false表示not_tag
*/
// tagMessage = new SendTagMessage("this is a specifies tags push message201.", 5 ,false);
tagMessage = new SendTagMessage("taglist message.", tagsList1,false);
tagMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tagMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagMessage.setProxyInfo(proxyInfo);
result = tagMessage.sendPush();
break;
case 21:
/**
* 单个的stag
*/
stagsList1 = new ArrayList<String[]>();
stagsList1.add(stags1);
stagsList1.add(stags2);
/**
* new一个SendStagMessage对象,传入消息内容和stag,stag可以是String串,或者String[]数组集合,最后一个参数true表示是tag,false表示not_tag
*/
stagMessage = new SendStagMessage("single stags push message.", "hello" ,true);
// stagMessage = new SendStagMessage("this is a last
// alias push message.", stagsList1,false);
stagMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
stagMessage.setIosPlatform(iosAppKey, iosSecretkey);
stagMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
stagMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagMessage.setProxyInfo(proxyInfo);
result = stagMessage.sendPush();
break;
case 22:
/**
* 给taglist发,且不给not_taglist发
*/
tagsList1 = new ArrayList<int[]>();
tagsList1.add(new int[] { 1 });
tagsList2 = new ArrayList<int[]>();
tagsList2.add(new int[] { 3, 8 });
/**
* new一个SendTagMessage对象,传入消息内容、taglist和not_taglist,taglist和not_taglist可以是int[]数组集合
*/
tagMessage = new SendTagMessage("this is a specifies tags push message.", tagsList1 ,tagsList2);
tagMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
tagMessage.setIosPlatform(iosAppKey, iosSecretkey);
tagMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
tagMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagMessage.setProxyInfo(proxyInfo);
result = tagMessage.sendPush();
break;
case 23:
/**
* 给staglist发,且不给not_staglist发
*/
stagsList1 = new ArrayList<String[]>();
stagsList1.add(stags1);
stagsList2 = new ArrayList<String[]>();
stagsList2.add(stags2);
/**
* new一个SendStagMessage对象,传入消息内容、staglist和not_staglist,staglist和not_staglist可以是String[]数组集合
*/
stagMessage = new SendStagMessage("this is a specifies tags push message23.", stagsList1 ,stagsList2);
stagMessage.setAndroidPlatform(androidAppKey, androidSecretkey);
stagMessage.setIosPlatform(iosAppKey, iosSecretkey);
stagMessage.setAndroidNotification(
new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
stagMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// tagMessage.setProxyInfo(proxyInfo);
result = stagMessage.sendPush();
break;
case 24:
// try {
// json1.put("body", "this is content.");
// json1.put("title", "this is title.");
// json2.put("ios", json1);
// json2.put("android", "this is a all push message3.");
// } catch (JSONException e1) {
// e1.printStackTrace();
// }
List<int[]> iosAppKeyList = new ArrayList<int[]>();
iosAppKeyList.add(iosKeys);
List<String[]> iosSecretkeyList = new ArrayList<String[]>();
iosSecretkeyList.add(iosSecretkeys);
/**
* 给一个Android和多个Ios客户端推送通知消息
* new一个SendAllMessage对象,传入Android和Ios的Appkey和Secretkey,并指定消息内容,消息内容若为string则iOS无title显示,若要添加iOS的title可如上述JSONObject写法
*/
SendAllMessage sendAllMessage1 = new SendAllMessage("one android and more than one ios message.", androidAppKey,
androidSecretkey, iosAppKeyList, iosSecretkeyList);
/**
* 默认为0:透传消息,1:通知消息, 当设置AndroidNotification或IosNotification时即为通知消息,
* 可以省略该属性
*/
sendAllMessage1.setIsNotify(1);
/**
* 非必须,详细参见开发文档,设置Android通知消息的内容及样式,传入AndroidNotification
*/
// sendAllMessage.setAndroidNotification(new AndroidNotification(true, false, "ixintui Push", 1, "", true).setBadge(6));
/**
* 非必须,详细参见开发文档,设置Android通知消息的内容及样式,传入IosNotification
*/
// sendAllMessage.setIosNotification(IosNotification.getInstance().setBadge(8).setCategory("category"));
/**
* 非必须,详细参见开发文档,设置消息选项,传入Option
*/
sendAllMessage1.setOption(Option.getInstance().setPeriod(80000).setQps(0).setTimed(0));
/* 设置代理 */
// ProxyInfo proxyInfo = new ProxyInfo("ip", 0);
// proxyInfo.setType(Proxy.Type.HTTP);
// proxyInfo.setUserName("username");
// proxyInfo.setPassword("password");
// sendAllMessage.setProxyInfo(proxyInfo);
result = sendAllMessage1.sendPush();
break;
}