|
|
@ -15,7 +15,6 @@ import cn.jpush.api.push.model.Platform;
|
|
|
|
import cn.jpush.api.push.model.PushPayload;
|
|
|
|
import cn.jpush.api.push.model.PushPayload;
|
|
|
|
import cn.jpush.api.push.model.audience.Audience;
|
|
|
|
import cn.jpush.api.push.model.audience.Audience;
|
|
|
|
import cn.jpush.api.push.model.notification.AndroidNotification;
|
|
|
|
import cn.jpush.api.push.model.notification.AndroidNotification;
|
|
|
|
import cn.jpush.api.push.model.notification.IosNotification;
|
|
|
|
|
|
|
|
import cn.jpush.api.push.model.notification.Notification;
|
|
|
|
import cn.jpush.api.push.model.notification.Notification;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -36,22 +35,20 @@ public class JpushMessageHelper {
|
|
|
|
return client;
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PushPayload makeSinglePayload(Set<String> clientIds, JpushMessage pushMessage) {
|
|
|
|
public PushPayload generateSinglePayload(Set<String> alias, JpushMessage pushMessage) {
|
|
|
|
Notification notify = getNotify(pushMessage);
|
|
|
|
Notification notify = getNotify(pushMessage);
|
|
|
|
return PushPayload.newBuilder()
|
|
|
|
return PushPayload.newBuilder()
|
|
|
|
.setPlatform(Platform.android_ios())
|
|
|
|
.setPlatform(Platform.android())
|
|
|
|
.setAudience(Audience.registrationId(clientIds))
|
|
|
|
.setAudience(Audience.alias(alias))
|
|
|
|
.setNotification(notify)
|
|
|
|
.setNotification(notify)
|
|
|
|
// 设置离线时长
|
|
|
|
// 设置离线时长
|
|
|
|
.setOptions(
|
|
|
|
.setOptions(Options.newBuilder().setTimeToLive(60*60*4).build()).build();
|
|
|
|
Options.newBuilder().setTimeToLive(600).build()).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Notification getNotify(JpushMessage pushMessage) {
|
|
|
|
private Notification getNotify(JpushMessage pushMessage) {
|
|
|
|
String alert = getText(pushMessage);
|
|
|
|
String alert = getText(pushMessage);
|
|
|
|
return Notification
|
|
|
|
return Notification
|
|
|
|
.newBuilder()
|
|
|
|
.newBuilder()
|
|
|
|
.addPlatformNotification(IosNotification.newBuilder().setAlert(alert).setSound("default").addExtras(getExtra(pushMessage)).build())
|
|
|
|
|
|
|
|
.addPlatformNotification(AndroidNotification.newBuilder().setTitle(pushMessage.getTitle()).setAlert(alert).addExtras(getExtra(pushMessage)).build()).build();
|
|
|
|
.addPlatformNotification(AndroidNotification.newBuilder().setTitle(pushMessage.getTitle()).setAlert(alert).addExtras(getExtra(pushMessage)).build()).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|