https://community.jiguang.cn/t/ios-title/27090
IosAlert iosAlert = IosAlert.newBuilder()
.setTitleAndBody("test alert", "subtitle", "test ios alert json")
.setActionLocKey("PLAY")
.build();
PushPayload payload = PushPayload
.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.alias(pushMsg.getAlias()))//Audience.alias(alias.replace(".", "_"))
.setNotification(
Notification
.newBuilder()
.addPlatformNotification(
IosNotification.newBuilder()
.setAlert(iosAlert)//notification
.setSound("happy.caf")
.addExtras(pushMsg.getExtras())//extras
.build())
public boolean sendNotificationWithAlias(com.wybs.bbs.dal.model.JPushMsg pushMsg){
try {
ClientConfig clientConfig = ClientConfig.getInstance();
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
jpushClient.getPushClient().setHttpClient(httpClient);
IosAlert iosAlert = IosAlert.newBuilder()
.setTitleAndBody(pushMsg.getTitle(), "", pushMsg.getAlert())
.build();
PushPayload payload = PushPayload
.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.alias(pushMsg.getAlias()))//Audience.alias(alias.replace(".", "_"))
.setNotification(
Notification
.newBuilder()
.addPlatformNotification(
IosNotification.newBuilder()
.setAlert(iosAlert)//notification
.setSound("default")
.addExtras(pushMsg.getExtras())//extras
.build())
.addPlatformNotification(
AndroidNotification.newBuilder()
.setAlert(pushMsg.getAlert())//notification
.setTitle(pushMsg.getTitle())
.addExtras(pushMsg.getExtras())//extras
.build())
.build())
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.build()).build();
PushResult result = jpushClient.sendPush(payload);
logger.debug("sendNotificationWithAlias() - push all - msgId={}, title={}, notification={}, alias={}, payload={}",result.msg_id, pushMsg.getTitle(), pushMsg.getAlert(), pushMsg.getAlias(), payload);
return result.isResultOK();
} catch (APIConnectionException e) {
logger.debug("APIConnectionException:"+e.getMessage());
e.printStackTrace();
} catch (APIRequestException e) {
logger.debug("APIConnectionException:"+e.getMsgId());
e.printStackTrace();
}
return false;
}