|
前端设置tag,alias;
后端
System.out.println(alias1);
ClientConfig config = ClientConfig.getInstance();
jpushClient = new JPushClient(secret, key, 3, null, config);
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.alias(alias1)) //.setAudience(Audience.alias("alias1"))Notification.alert("亲爱的聚好多用户,已经成功登陆..")
.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().setAlert("亲爱用户,已经成功登陆..").build())
.addPlatformNotification(IosNotification.newBuilder().setAlert("亲爱用户,已经成功登陆..").setSound("default").setContentAvailable(false).build()).build())
.build();
payload.resetOptionsTimeToLive(86400);
payload.resetOptionsApnsProduction(apnsProduction);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar nowTime = Calendar.getInstance();
nowTime.add(Calendar.MINUTE, 1);
String scheduleTime =sdf.format(nowTime.getTime());
ScheduleResult result = jpushClient.createSingleSchedule(UUID.randomUUID().toString().replaceAll("-", ""), scheduleTime, payload);
return result;
}
报错:
[http-8080-2] WARN cn.jpush.api.common.connection.NativeHttpClient - Got error response - responseCode:400, responseContent:{"error":{"message":"The schedule-task is invalid, push is invalid:cannot find user by this audience","code":8100}}
[http-8080-2] ERROR cn.jpush.api.common.connection.NativeHttpClient - Your request params is invalid. Please check them according to error message.
备注:用外卖案例的 极光id是没有问题的,应业务需要别名
|
|