1.问题:IOS推送没有声音和震动提示
在生产环境中用户接收到消息推送后没有声音和震动提醒,用户手机在设置中对我们app应用通知栏是开启了声音及震动设置的
之前发送消息推送的写法是
getJPushClient().sendIosNotificationWithRegistrationID(msgContent, null, registrationID);
发送成功后在极光后台选择api过滤,然后查看推送详情
2.通过极光的web后台直接推送给该regId,可以接收到声音和震动
3.解决方法
通过构建推送对象,然后设置相应的参数来解决
//向IOS平台推送消息 JpushHelper.getJPushClient().sendPush(JpushHelper.buildPushObject_ios_audienceMore_regId(registrationID, msgContent));
/**
* 构建推送对象:平台是 Andorid 与 iOS,按照registrationId推送
* 推送内容是 - 内容为 msgContent 的消息,并且附加字段 from = JPush。
* 作者:温海金
* 最后更改时间 : 2017年2月20日 下午4:20:46
*/
public static PushPayload buildPushObject_ios_audienceMore_regId(String registrationId,String msgContent) {
return PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.registrationId(registrationId))
.setNotification(Notification.newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
.setAlert(msgContent)
.setBadge(5)
.setSound("default")//这一步是关键,设置默认声音,这样就会使用手机本身的设置
.addExtra("from", "Jpush")
.build())
.build())
.build();
}
修改完成后,推送IOS可以得到声音及震动提醒