java集成极光,后台推送定时任务不报异常,但消息收不到?
java集成极光,后台推送定时任务不报异常,但消息收不到?
断点一路跟了一下,也没有发现不对的地方。。。。。。
/**
* 向指定用户推送定时消息
*
* @decripe 定时推送,利用alias做别名,点对点发送,同时记录返回的结果
* @param message推送对象,alias设备识别码,定时的时间date,MsgType推送的业务类型,
* name推送的名称
*/
public static ScheduleResult sendSchedulePush(String message, Set<String> registrationIds, Date date, String MsgType,
String name) {
JPushClient jPushClient = new JPushClient(masterSecret, appKey);
String objStr = message;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = format.format(date);
ScheduleResult result = null;
PushPayload push = null;
if(registrationIds == null ||"".equals(registrationIds)){
push = PushPayload.newBuilder().setPlatform(Platform.all())
.setMessage(Message.newBuilder().setMsgContent(objStr)
.build())
.setAudience(Audience.all()).build();
}else{
push = PushPayload.newBuilder().setPlatform(Platform.android())
.setMessage(Message.newBuilder().setMsgContent(objStr)
.build())
.setAudience(Audience.registrationId(registrationIds)).build();
}
try {
result = jPushClient.createSingleSchedule(name, time, push);
// LOG.info("Got result - " + result);
// LOG.info("send objStr - " + objStr);
// System.out.println(result);
// System.out.println(objStr);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
return result;
}