本文整理汇总了Java中cn.jpush.api.JPushClient类的典型用法代码示例。如果您正苦于以下问题:Java JPushClient类的具体用法?Java JPushClient怎么用?Java JPushClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPushClient类属于cn.jpush.api包,在下文中一共展示了JPushClient类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getInstance
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public static JPushUtil getInstance(String key){
if(BasicUtil.isEmpty(key)){
key = "default";
}
JPushUtil util = instances.get(key);
if(null == util){
util = new JPushUtil();
JPushConfig config = JPushConfig.getInstance(key);
util.config = config;
ClientConfig clientConfig;
clientConfig = ClientConfig.getInstance();
clientConfig.setApnsProduction(false);
clientConfig.setTimeToLive(60 * 60 * 24);
util.client = new JPushClient(config.MASTER_SECRET, config.APP_KEY, null, clientConfig);
instances.put(key, util);
}
return util;
}
开发者ID:anylineorg,项目名称:anyline,代码行数:21,代码来源:JPushUtil.java
示例2: updateDeviceTagAlias
import cn.jpush.api.JPushClient; //导入依赖的package包/类
@Override
public DefaultResult updateDeviceTagAlias(String jpushId,String alias, Set<String> tagsToAdd){
try{
logger.info("updateDeviceTagAlias():jpushId:"+jpushId);
JPushClient jpushClient = getJpushClient();
DefaultResult defaultResult = jpushClient.updateDeviceTagAlias(jpushId, true, true);
logger.info("updateDeviceTagAlias():result:"+defaultResult);
defaultResult = jpushClient.updateDeviceTagAlias(jpushId, alias, tagsToAdd,null);
logger.info("updateDeviceTagAlias():result:"+defaultResult);
return defaultResult;
}catch(Exception e){
logger.error("updateDeviceTagAlias():e:"+e.getMessage(),e);
return null;
}
}
开发者ID:cpusoft,项目名称:common,代码行数:17,代码来源:AppPushServiceImpl.java
示例3: testDefaultClient
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public static void testDefaultClient() {
JPushClient client = new JPushClient(PushConfig.masterSecret, PushConfig.appKey);
// JPushClient client1 = new JPushClient(masterSecret, appKey, null, ClientConfig.getInstance());
try {
client.sendPush("1111");
} catch (APIConnectionException | APIRequestException e) {
e.printStackTrace();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:11,代码来源:ClientExample.java
示例4: testCustomClient
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public static void testCustomClient() {
ClientConfig config = ClientConfig.getInstance();
config.setMaxRetryTimes(5);
config.setConnectionTimeout(10 * 1000); // 10 seconds
config.setSSLVersion("TLSv1.1"); // JPush server supports SSLv3, TLSv1, TLSv1.1, TLSv1.2
JPushClient jPushClient = new JPushClient(PushConfig.masterSecret, PushConfig.appKey, null, config);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:10,代码来源:ClientExample.java
示例5: push
import cn.jpush.api.JPushClient; //导入依赖的package包/类
@Override
public boolean push(String alias, List<String> pushTags, String alert) {
try{
logger.info("push():alias:"+alias+" pushTags:"+pushTags+" alert:"+alert);
JPushClient jpushClient = getJpushClient();
Builder builder = PushPayload.newBuilder()
.setPlatform(Platform.all());//所有平台
if(StringUtils.isNotBlank(alias)){
builder = builder.setAudience(Audience.alias(alias));//向选定的人推送
}
if(pushTags!=null && pushTags.size()>0){
builder = builder.setAudience(Audience.tag(pushTags));//根据标签推送
}
if(StringUtils.isBlank(alias) && (pushTags==null || pushTags.size()==0)){
builder = builder.setAudience(Audience.all());
}
// PushPayload pushPayload = PushPayload.alertAll(content);
PushPayload pushPayload = builder.setNotification(Notification.alert( alert))//消息内容
.build();
logger.info("push():pushPayload:"+pushPayload);
PushResult result = jpushClient.sendPush(pushPayload);
logger.info("push():result:"+result);
return result.isResultOK();
}catch(Exception e){
logger.error("push():e:"+e.getMessage(),e);
return false;
}
}
开发者ID:cpusoft,项目名称:common,代码行数:30,代码来源:AppPushServiceImpl.java
示例6: getTagAlias
import cn.jpush.api.JPushClient; //导入依赖的package包/类
@Override
public TagAliasResult getTagAlias(String jpushId){
try{
logger.info("getTagAlias():jpushId:"+jpushId);
JPushClient jpushClient = getJpushClient();
TagAliasResult result = jpushClient.getDeviceTagAlias(jpushId);
logger.info("getTagAlias():result:"+result);
return result;
}catch(Exception e){
logger.error("push():e:"+e.getMessage(),e);
return null;
}
}
开发者ID:cpusoft,项目名称:common,代码行数:14,代码来源:AppPushServiceImpl.java
示例7: PushInfoThread
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public PushInfoThread(Equipment equipment, String title, String content,
Map<String, String> params) {
super();
this.equipment = equipment;
this.title = title;
this.content = content;
this.params = params;
jpushClient = new JPushClient(CommonVariables.MASTER_SECRET,
CommonVariables.APPKEY);
}
开发者ID:hongdong,项目名称:FindMe_Server,代码行数:11,代码来源:PushInfoThread.java
示例8: PushListInfoThread
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public PushListInfoThread(List<Equipment> equipments, String title,
String content, Map<String, String> params) {
super();
this.equipments = equipments;
this.title = title;
this.content = content;
this.params = params;
jpushClient = new JPushClient(CommonVariables.MASTER_SECRET,
CommonVariables.APPKEY);
}
开发者ID:hongdong,项目名称:FindMe_Server,代码行数:11,代码来源:PushListInfoThread.java
示例9: jPushClient
import cn.jpush.api.JPushClient; //导入依赖的package包/类
/**
* 创建JpushClient
*
* @return
*/
private JPushClient jPushClient() {
ClientConfig clientConfig = ClientConfig.getInstance();
JPushClient jpushClient = new JPushClient(this.MASTER_SECRET, this.APPKEY, null, clientConfig);
return jpushClient;
}
开发者ID:noseparte,项目名称:Spring-Boot-Server,代码行数:11,代码来源:PushServiceForCall.java
示例10: _pushToAndroid
import cn.jpush.api.JPushClient; //导入依赖的package包/类
private static void _pushToAndroid(String ak, String sk, String title, String content, Map<String, String> extras, String[] alias, String[] registrationIds, boolean willSilence) throws APIConnectionException, APIRequestException {
//初始化
JPushClient jpush = new JPushClient(sk, ak);
//构造推送的字段
//extras
//开始推送
PushResult res = null;
String mode = "未知";
if(isEmpty(alias) && isEmpty(registrationIds)){
throw new RuntimeException("别名和极光id不能同时为空,测试环境不要给所有人推");
}
if(willSilence){
if(alias == null || alias.length == 0){
///极光id,静默模式
mode = "静默推送,按照RegistrationID";
res = jpush.sendAndroidMessageWithRegistrationID(title, content, registrationIds);
}else{
///别名,静默模式
mode = "静默推送,按照别名";
res = jpush.sendAndroidMessageWithAlias(title, content, alias);
}
}else{
if(alias == null || alias.length == 0){
///极光id,非静默模式
mode = "非静默推送,按照RegistrationID";
res = jpush.sendAndroidNotificationWithRegistrationID(title, content, extras, registrationIds);
}else{
///别名,非静默模式
mode = "非静默推送,按照别名";
//res = jpush.sendNotificationAll("hahahah");
res = jpush.sendAndroidNotificationWithAlias(title, content, extras, alias);
}
}
System.out.println("推送模式:" + mode);
if (res != null) {
if (res.isResultOK()) {
System.out.println("推送结果:发送成功");
} else {
System.out.println("推送结果:发送失败");
}
} else {
System.out.println("推送结果:无法获取返回数据");
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:50,代码来源:JPushUtils.java
示例11: getJpushClient
import cn.jpush.api.JPushClient; //导入依赖的package包/类
private JPushClient getJpushClient(){
return new JPushClient(masterSecret, appKey,null,clientConfig);
}
开发者ID:cpusoft,项目名称:common,代码行数:4,代码来源:AppPushServiceImpl.java
示例12: testCustomPushClient
import cn.jpush.api.JPushClient; //导入依赖的package包/类
public static void testCustomPushClient() {
ClientConfig config = ClientConfig.getInstance();
config.setApnsProduction(false); // development env
config.setTimeToLive(60 * 60 * 24); // one day
// config.setGlobalPushSetting(false, 60 * 60 * 24); // development env, one day
JPushClient jPushClient = new JPushClient(PushConfig.masterSecret, PushConfig.appKey, null, config); // JPush client
// PushClient pushClient = new PushClient(masterSecret, appKey, null, config); // push client only
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:14,代码来源:ClientExample.java
注:本文中的cn.jpush.api.JPushClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论