本文整理汇总了Java中cn.jpush.api.push.model.notification.AndroidNotification类的典型用法代码示例。如果您正苦于以下问题:Java AndroidNotification类的具体用法?Java AndroidNotification怎么用?Java AndroidNotification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndroidNotification类属于cn.jpush.api.push.model.notification包,在下文中一共展示了AndroidNotification类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildPushObject_android_regId_alert
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
private static PushPayload buildPushObject_android_regId_alert(String pushAlert, String pushTitle, List<String> regIds) {
Map<String, String> extras = new HashMap<String, String>();
extras.put("extra_1", "val1");
extras.put("extra_2", "val2");
return PushPayload.newBuilder()
.setPlatform(Platform.android())
.setAudience(Audience.registrationId(regIds))
.setNotification(Notification
.newBuilder()
.setAlert(pushAlert)
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle(pushTitle)
.addExtras(extras)
.build())
.build())
.build();
}
开发者ID:IaHehe,项目名称:classchecks,代码行数:20,代码来源:JPushUtils.java
示例2: buildPushObject_id_alert_title_extra
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
/**
*
* @param MSG_CONTENT 消息内容
* @param ALERT alert
* @param TITLE 标题 //ios没有title
* @param extra 附加参数
* @param regid 用户注册id
* @return
*/
public PushPayload buildPushObject_id_alert_title_extra(String ALERT,String TITLE,Map<String, String> extra,String regId) {
Audience registrationId;
if(regId!=null){
registrationId = Audience.registrationId(regId);
}else{
registrationId = Audience.all();
}
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(registrationId)
.setNotification(Notification.newBuilder()
.setAlert(ALERT)
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle(TITLE).addExtras(extra).build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtras(extra).build())
.build())
//.setMessage(Message.content(MSG_CONTENT))
.build();
}
开发者ID:noseparte,项目名称:Spring-Boot-Server,代码行数:31,代码来源:PushService.java
示例3: isGlobalExceedLength
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
public boolean isGlobalExceedLength() {
int messageLength = 0;
JsonObject payload = (JsonObject) this.toJSON();
if (payload.has(MESSAGE)) {
JsonObject message = payload.getAsJsonObject(MESSAGE);
messageLength = message.toString().getBytes().length;
}
if (!payload.has(NOTIFICATION)) {
// only mesage
return messageLength > MAX_GLOBAL_ENTITY_LENGTH;
} else {
JsonObject notification = payload.getAsJsonObject(NOTIFICATION);
if (notification.has(AndroidNotification.NOTIFICATION_ANDROID)) {
JsonObject android = notification.getAsJsonObject(AndroidNotification.NOTIFICATION_ANDROID);
int androidLength = android.toString().getBytes().length;
return (androidLength + messageLength) > MAX_GLOBAL_ENTITY_LENGTH;
}
}
return false;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:21,代码来源:PushPayload.java
示例4: buildPushObject_android_tags_alert
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
/**
*
* @Title: buildPushObject_all_tags_teacher_alert
* @Description: TODO(学生端)
* @return
* PushPayload
*/
private static PushPayload buildPushObject_android_tags_alert(String tag, String pushAlert, String pushTitle) {
return PushPayload.newBuilder()
.setPlatform(Platform.android())//设置接受的平台
.setAudience(Audience.tag(tag))//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
.setNotification(Notification.newBuilder()
.setAlert(pushAlert)
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle(pushTitle).build())
.build())
.build();
}
开发者ID:IaHehe,项目名称:classchecks,代码行数:19,代码来源:JPushUtils.java
示例5: buildPushObject_android_and_ios
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
public static PushPayload buildPushObject_android_and_ios() {
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.tag("tag1"))
.setNotification(Notification.newBuilder()
.setAlert("alert content")
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle("Android Title").build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("extra_key", "extra_value").build())
.build())
.build();
}
开发者ID:xiaowei1118,项目名称:java_server,代码行数:15,代码来源:JpushInterface.java
示例6: buildPushPayload
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
private static PushPayload buildPushPayload(long userID, String alert, ONode data) {
//1.预处理
String data1 = null;
if (data != null && data.count() > 0)
data1 = data.toJson();
String alert1 = null;
if (alert != null && alert.length() > 0)
alert1 = alert;
//2.建构消息体
if (alert1 != null && data1 != null) {
//2.1.同时推送提醒和数据
int cmd = data.get("CMD").getInt();
data.remove("CONTENT");
data1 = data.toJson();
PushPayload.Builder builder = PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(Audience.alias(Long.toString(userID))) //给别名为alias1的用户推送
.setNotification(Notification.newBuilder()
.setAlert(alert1)
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("content", data1)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("content", data1)
.setSound("default")
.build())
.build())
.setOptions(Options.newBuilder().setApnsProduction((userID > 10020 ? true : isApnsProduction)).build());
return builder.build();
} else {
if (data1 != null) {
//2.2.只推送透传数据
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(Audience.alias(Long.toString(userID))) //给别名为alias1的用户推送
.setMessage(Message.content(data1)) //data1
.setOptions(Options.newBuilder().setApnsProduction((userID > 10020 ? true : isApnsProduction)).build())
.build();
}
if (alert1 != null) { //此哪data2 == null
//2.3.只推送提醒
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(Audience.alias(Long.toString(userID))) //给别名为alias1的用户推送
.setNotification(Notification.newBuilder()
.setAlert(alert1)
.addPlatformNotification(AndroidNotification.newBuilder()
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.setSound("default")
.build())
.build())
.setOptions(Options.newBuilder().setApnsProduction((userID > 10020 ? true : isApnsProduction)).build())
.build();
}
return null;
}
}
开发者ID:noear,项目名称:Snacks,代码行数:72,代码来源:PushApi.java
示例7: buildPushPayload2
import cn.jpush.api.push.model.notification.AndroidNotification; //导入依赖的package包/类
private static PushPayload buildPushPayload2(String alert, ONode data,List<Long> userIDs) {
//1.预处理
String data1 = null;
if (data != null && data.count() > 0)
data1 = data.toJson();
String alert1 = null;
if (alert != null && alert.length() > 0)
alert1 = alert;
//2.建构消息体
if (alert1 != null && data1 != null) {
//2.1.同时推送提醒和数据
int cmd = data.get("CMD").getInt();
data.remove("CONTENT");
data1 = data.toJson();
PushPayload.Builder builder = PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(alias2(userIDs)) //给别名为alias1的用户推送
.setNotification(Notification.newBuilder()
.setAlert(alert1)
.addPlatformNotification(AndroidNotification.newBuilder()
.addExtra("content", data1)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("content", data1)
.setSound("default")
.build())
.build())
.setOptions(Options.newBuilder().setApnsProduction(true).build());
// if(cmd!=12)
// builder.setMessage(Message.content(data1)); //data1
return builder.build();
} else {
if (data1 != null) {
//2.2.只推送透传数据
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(alias2(userIDs)) //给别名为alias1的用户推送
.setMessage(Message.content(data1)) //data1
.setOptions(Options.newBuilder().setApnsProduction(true).build())
.build();
}
if (alert1 != null) { //此哪data2 == null
//2.3.只推送提醒
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios()) //构建推送对象为ios和android
.setAudience(alias2(userIDs)) //给别名为alias1的用户推送
.setNotification(Notification.newBuilder()
.setAlert(alert1)
.addPlatformNotification(AndroidNotification.newBuilder()
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.setSound("default")
.build())
.build())
.setOptions(Options.newBuilder().setApnsProduction(true).build())
.build();
}
return null;
}
}
开发者ID:noear,项目名称:Snacks,代码行数:74,代码来源:PushApi.java
注:本文中的cn.jpush.api.push.model.notification.AndroidNotification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论