DCloud_App_Array
DCloud_App_Array
  • 发布:2019-02-25 20:25
  • 更新:2024-05-29 10:27
  • 阅读:604444

UniPush使用指南

分类:uni-app

要回复文章请先登录注册

老哥教教我

老哥教教我

回复 1***@qq.com :
在开发者中心UinPush里 配置管理,应用配置,里面有,填写到后端就可以了
2019-07-16 08:54
1***@qq.com

1***@qq.com

回复 老哥教教我 :
app的推送 appid怎么设置,我在uni-push的文档中并没有看到个推的appid设置
2019-07-16 08:46
dfl

dfl

###请教各位:java服务端 使用透传消息模板 推送消息,应用离线时,可以收到, 应用在线时收不到 这是什么问题?
客户端是5+app
```
public void PushtoSingle(PushInfo pushInfo){
IGtPush push = new IGtPush(config.getApiurl(),config.getAppKey(),config.getMasterSecret());
TransmissionTemplate template = getTransmissionTemplate(pushInfo);
SingleMessage message = new SingleMessage();
message.setOffline(true);
// 离线有效时间,单位为毫秒,可选
message.setOfflineExpireTime(24 * 3600 * 1000);
message.setData(template);
// 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
message.setPushNetWorkType(0);
Target target = new Target();
target.setAppId(config.getAppId());
target.setClientId(pushInfo.getClientId());

//target.setAlias(Alias);
IPushResult ret = null;
try {
ret = push.pushMessageToSingle(message, target);
} catch (RequestException e) {
e.printStackTrace();
ret = push.pushMessageToSingle(message, target, e.getRequestId());
}
if (ret != null) {
System.out.println(ret.getResponse().toString());
} else {
System.out.println("服务器响应异常");
}
}


public TransmissionTemplate getTransmissionTemplate(PushInfo pushInfo){

QnPushPayLoad payLoad=new QnPushPayLoad();
payLoad.setTitle(pushInfo.getNotifyTitle());
payLoad.setContent(pushInfo.getNotityText());
payLoad.setPayload("test");

String payLoadJson= JsonUtil.javaObjectToJsonString(payLoad);
String intent="intent:#Intent;launchFlags=0x14000000;action=android.intent.action.oppopush;package=";
intent+= config.getPackageName();
intent+=";component=";
intent+= config.getPackageName();
intent+="/io.dcloud.PandoraEntry;";
intent+="S.UP-OL-SU=true;S.title=";
intent+=pushInfo.getNotifyTitle();
intent+=";S.content=";
intent+=pushInfo.getNotityText();
intent+=";S.payload=test;end";
TransmissionTemplate template = new TransmissionTemplate();
template.setAppId(config.getAppId());
template.setAppkey(config.getAppKey());
template.setTransmissionContent(pushInfo.getNotityText());
template.setTransmissionType(2);
Notify notify = new Notify();
notify.setTitle(pushInfo.getNotifyTitle());
notify.setContent(pushInfo.getNotityText());
notify.setIntent(intent);
notify.setType(GtReq.NotifyInfo.Type._intent);
notify.setPayload(payLoadJson);
template.set3rdNotifyInfo(notify);//设置第三方通知
return template;
}
```
2019-07-15 21:51
dfl

dfl

回复 4***@qq.com :
自己维护一个clientid与用户的关系表:客户端 获取clientid 然后上传到自己的服务器上,,
推送时: 根据用户取clientid,然后调用服务端sdk发送
2019-07-15 21:49
4***@qq.com

4***@qq.com

问下想给特定用户推消息该怎么做,怎么绑定用户信息呢?
2019-07-15 20:57
dfl

dfl

请教各位:java服务端 使用透传消息模板 推送消息,应用离线时,可以收到, 应用在线时收不到 这是什么问题?

public void PushtoSingle(PushInfo pushInfo){
IGtPush push = new IGtPush(config.getApiurl(),config.getAppKey(),config.getMasterSecret());
TransmissionTemplate template = getTransmissionTemplate(pushInfo);
SingleMessage message = new SingleMessage();
message.setOffline(true);
// 离线有效时间,单位为毫秒,可选
message.setOfflineExpireTime(24 * 3600 * 1000);
message.setData(template);
// 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
message.setPushNetWorkType(0);
Target target = new Target();
target.setAppId(config.getAppId());
target.setClientId(pushInfo.getClientId());

//target.setAlias(Alias);
IPushResult ret = null;
try {
ret = push.pushMessageToSingle(message, target);


} catch (RequestException e) {
e.printStackTrace();
ret = push.pushMessageToSingle(message, target, e.getRequestId());
}
if (ret != null) {
System.out.println(ret.getResponse().toString());
} else {
System.out.println("服务器响应异常");
}
}


public TransmissionTemplate getTransmissionTemplate(PushInfo pushInfo){
String payLoad="{\"title\":\""+pushInfo.getNotifyTitle()+"\",\"content\":\""+pushInfo.getNotityText()+"\",\"payload\":\"test\"}";
String intent="intent:#Intent;launchFlags=0x14000000;action=android.intent.action.oppopush;package=";
intent+= config.getPackageName();
intent+=";component=";
intent+= config.getPackageName();
intent+="/io.dcloud.PandoraEntry;";
intent+="S.UP-OL-SU=true;S.title=";
intent+=pushInfo.getNotifyTitle();
intent+=";S.content=";
intent+=pushInfo.getNotityText();
intent+=";S.payload=test;end";
TransmissionTemplate template = new TransmissionTemplate();
template.setAppId(config.getAppId());
template.setAppkey(config.getAppKey());
template.setTransmissionContent(pushInfo.getNotityText());
template.setTransmissionType(2);
Notify notify = new Notify();
notify.setTitle(pushInfo.getNotifyTitle());
notify.setContent(pushInfo.getNotityText());
notify.setIntent(intent);
notify.setType(GtReq.NotifyInfo.Type._intent);
notify.setPayload(payLoad);
// notify.setUrl("https://dev.getui.com/");
//notify.setType(Type._url);
template.set3rdNotifyInfo(notify);//设置第三方通知
return template;
}
2019-07-15 19:17
老哥教教我

老哥教教我

回复 1***@qq.com :
说明推送 appid不是这个app获取的,或者填写错误
2019-07-15 13:27
bishuihanshan

bishuihanshan

我是以前HBuilder做的Mui的项目,不是uni-app类型的项目,怎么办
2019-07-14 20:35
1***@qq.com

1***@qq.com

我在服务端调用个推进行推送,会提示错误AppidError,这个是什么原因
2019-07-14 17:35
DCloud_App_Array

DCloud_App_Array (作者)

回复 老哥教教我 :
调用Web API下发推送消息有问题?把服务代码发出来看下(私信发下载地址)
2019-07-13 18:48