最近我将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;
}
...
11 个评论
要回复文章请先登录或注册
魏小鹏 (作者)
魏小鹏 (作者)
为人方正实诚
7***@qq.com
lijunshuai
m***@163.com
DCloud_heavensoft
7***@qq.com
7***@qq.com
Hb传道者