本文整理汇总了Java中cn.jpush.api.JPushClient.sendPush方法的典型用法代码示例。如果您正苦于以下问题:Java JPushClient.sendPush方法的具体用法?Java JPushClient.sendPush怎么用?Java JPushClient.sendPush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.jpush.api.JPushClient
的用法示例。
在下文中一共展示了JPushClient.sendPush方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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;
}
}