|
public static ScheduleResult sendPushMessage(String registrationId, String key, String secret) throws APIConnectionException, APIRequestException{
ClientConfig config = ClientConfig.getInstance();
HttpProxy proxy = null;
if (useProxy) {
proxy = new HttpProxy("http-proxy.system", 3128);
}
jpushClient = new JPushClient(secret, key, 3, proxy, config);
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.registrationId(registrationId))
.setNotification(Notification.alert("亲,您的订单已准备完毕,请来就餐.."))
.build();
payload.resetOptionsTimeToLive(86400);
payload.resetOptionsApnsProduction(apnsProduction);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar nowTime = Calendar.getInstance();
nowTime.add(Calendar.MINUTE, 2);
String scheduleTime =sdf.format(nowTime.getTime());
ScheduleResult result = jpushClient.createSingleSchedule(UUID.randomUUID().toString().replaceAll("-", ""), scheduleTime, payload);
return result;
} |
|