问题:IOS8注册推送,推送消息能到达手机,但没有声音,首次安装App进入系统后,也没有是否允许推送的提示。
原因:
注册推送时,仅调用了UIApplication.registerForRemoteNotifications(),未设置通知的参数;
解决:
let application = UIApplication.sharedApplication()
/* 注册通知 */
if application.respondsToSelector("registerForRemoteNotifications") {
let setting = UIUserNotificationSettings(forTypes: .Alert | .Sound | .Badge, categories: nil)
application.registerUserNotificationSettings(setting)
application.registerForRemoteNotifications()
} else {
application.registerForRemoteNotificationTypes(.Badge | .Sound | .Alert)
}

本文介绍了一种iOS应用中推送消息无法触发声音的问题及其解决方案。主要原因是注册推送时未正确设置通知参数。通过使用UIUserNotificationSettings并指定Alert、Sound和Badge类型,可以确保推送消息在iOS设备上正确显示并伴有声音。
1262

被折叠的 条评论
为什么被折叠?



