//根据cid进行单推
PushDTO<Audience> pushDTO = new PushDTO<Audience>();
// 设置个推推送参数
pushDTO.setRequestId(System.currentTimeMillis() + "");
PushMessage pushMessage = new PushMessage();
pushDTO.setPushMessage(pushMessage);
GTNotification notification = new GTNotification();
pushMessage.setNotification(notification);
notification.setTitle("标题" + new Date());
notification.setBody("body");
notification.setClickType("url");
notification.setUrl("https://www.getui.com");
//设置推送条件
Settings settings = new Settings();
settings.setTtl(1000 * 60);
pushDTO.setSettings(settings);
// 设置接收人信息
Audience audience = new Audience();
pushDTO.setAudience(audience);
audience.addCid(clientId);
//设置厂商推送消息参数
PushChannel pushChannel = new PushChannel();
AndroidDTO androidDTO = new AndroidDTO();
Ups ups = new Ups();
// ups.setTransmission("透传消息,消息内容");
ThirdNotification thirdNotification = new ThirdNotification();
thirdNotification.setClickType(CommonEnum.ClickTypeEnum.TYPE_STARTAPP.type);
thirdNotification.setTitle("" + System.currentTimeMillis());
thirdNotification.setBody("content");
ups.setNotification(thirdNotification);
ups.addOption("HW", "badgeAddNum", 3);
ups.addOption("HW", "badgeClass", "com.getui.demo.GetuiSdkDemoActivity");
ups.addOption("OP", "app_message_id", 11);
ups.addOption("VV", "message_sort", 1);
ups.addOption("XM", "channel", "2882303761519844378");
ups.addOptionAll("channel", "default");
androidDTO.setUps(ups);
pushChannel.setAndroid(androidDTO);
pushDTO.setPushChannel(pushChannel);
PushApi pushApi = createPushApi();
// 进行cid单推
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
if (apiResult.isSuccess()) {
// success
System.out.println(apiResult.getData());
} else {
// failed
System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
}
}```

- 发布:2021-08-20 15:50
- 更新:2021-08-23 09:59
- 阅读:1271
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win7
HBuilderX类型: 正式
HBuilderX版本号: 3.2.2
手机系统: Android
手机系统版本号: Android 11
手机厂商: 小米
手机机型: K30S Ultra
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
重新请求接口
重新请求接口
预期结果:
可以收到厂推
可以收到厂推
实际结果:
手机未收到厂商消息
手机未收到厂商消息
bug描述:
使用Uni Push传统服务端 SDK推送个推消息
当设备离线时,调用【toSingle】执行cid单推 返回结果如下,但是真机实际并没有收到消息
ApiResult{code=0, msg='success', data={RASS_0820_1cc13a2c812dc20aeb15f2cb5add282b={8eda75e21966221ecaf6498b37681f39=successed_offline}}}
不懂为什么离线厂商消息收不到,app在线时是可以收到个推消息的
1 个回复
h***@qq.com (作者)
已解决,原来是多厂商参数不匹配