魏小鹏
魏小鹏
  • 发布:2019-04-10 09:13
  • 更新:2022-12-25 01:21
  • 阅读:4344

UniPush的推送到达率太低

分类:uni-app

最近我将APP的推送从个推改成了UniPush,可是我发现推送的到达率好低呀,我每次重启一下APP之后的第一条推送可能收到,后续的推送一条也收不到了。。。

其中java中的核心方法我贴出来了,各位大佬可以帮忙瞅瞅,有什么大问题吗?

/**  
     * intent模板  
     */  
    private static String intentTemplate = "intent:#Intent;action=android.intent.action.oppopush;component=%s/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=%s;S.content=%s;S.payload=%s;end";  

/**  
     * 获取管理APP Intent信息  
     * @param pushMessage 管理员推送消息  
     * @return intent字符串  
     */  
    private static String getManagerIntent(PushMessage pushMessage) {  
        return String.format(intentTemplate, managerAppProperties.getPackageName(), pushMessage.getTitle(), pushMessage.getContent(), ObjectUtils.toJson(pushMessage.getPayload()));  
    }  

    /**  
     * 获取司机APP Intent信息  
     * @param pushMessage 司机端推送的消息  
     * @return intent 字符串  
     */  
    private static String getDriverIntent(PushMessage pushMessage) {  
        return String.format(intentTemplate, driverAppProperties.getPackageName(), pushMessage.getTitle(), pushMessage.getContent(), ObjectUtils.toJson(pushMessage.getPayload()));  
    }  

   /**  
     * 创建透传模板  
     * @param pushMessage 透传消息对象  
     * @param manager 是否是管理员透传消息  
     * @return 透传模板  
     */  
    private static TransmissionTemplate createTransmissionTemplate(PushMessage pushMessage, boolean manager) {  
        // 创建模板  
        TransmissionTemplate template = new TransmissionTemplate();  
        if (manager) {  
            template.setAppId(managerAppProperties.getAppId());  
            template.setAppkey(managerAppProperties.getAppKey());  
        } else {  
            template.setAppId(driverAppProperties.getAppId());  
            template.setAppkey(driverAppProperties.getAppKey());  
        }  

        template.setTransmissionType(2);  
        template.setTransmissionContent(ObjectUtils.toJson(pushMessage));  

        Notify notify = new Notify();  
        notify.setTitle(pushMessage.getTitle());  
        notify.setContent(pushMessage.getContent());  
        notify.setIntent(manager ? getManagerIntent(pushMessage) : getDriverIntent(pushMessage));  
        notify.setType(GtReq.NotifyInfo.Type._intent);  

        template.set3rdNotifyInfo(notify);  
        return template;  
    }  

...
0 关注 分享

要回复文章请先登录注册

lijunshuai

lijunshuai

兄弟,你已经很好了,我都发不出去,也找不到原因cid一直是null,预计发送人数是0,吐血了快
2019-08-15 16:54