java集成极光,后台推送定时任务不报异常,但消息收不到?

89a0b576869e1f67b8b9
2018-10-09 10:07 1.4k 0

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;
    }

1个回答

热门排序
  • 去官网查看 你推送的这条定时消息的历史记录。 可提供消息的 MessageID和收不到消息的设备的registrationID 来定位查询https://community.jiguang.cn/article/51501 看代码,你推送的 展示全部