"未获得用户播放声音的许可"对于ios设备

时间:2015-02-11 09:37:20

标签: ios swift push-notification server-push

在我的应用中推送服务器通知时,我的设备无法播放声音。我搜索了很多,我尝试了所有推荐的解决方案,但我无法解决问题。不过,它给出了为问题标题写的错误。

这是我的代码:

// Register for Push Notitications, if running iOS 8
if (application.respondsToSelector(Selector("registerUserNotificationSettings:"))) {
   var userNotificationTypes: UIUserNotificationType = (.Alert | .Badge | .Sound)
   var settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
   application.registerUserNotificationSettings(settings)
   application.registerForRemoteNotifications()
}
else
{
   // Register for Push Notifications earlier from iOS 8
   application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound)
}

你能帮我吗?

感谢您的回答,

祝你好运

注意:我调试了“didReceiveRemoteNotification”方法,并且通知声音已经显示为“默认”。

0 个答案:

没有答案