尝试请求用户通知权限时出错

时间:2014-12-07 02:31:20

标签: swift notifications

我尝试为我的应用设置通知。我按照本教程中的说法执行操作:http://thecodeninja.tumblr.com/post/89942124085/notifications-in-ios-8-part-1-using-swift-what

但我的应用程序在

崩溃了
var notificationSetting: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories: nil)

除了(lldb)

之外,控制台中没有任何内容

我看了我的日志,这就是我得到的:

Dec  6 21:25:14 iPhoneName <Warning>: Could not create service named com.apple.xcode.debug-gauge-data-providers.procinfo

我在IOS 7上我知道我不需要IOS 7的用户权限,但我也不想与IOS 8兼容

1 个答案:

答案 0 :(得分:1)

iOS 8.0及更高版本中提供了

UIUserNotificationSettingsUIUserNotificationSettings Class Reference

您的代码崩溃,因为iOS 7中没有该API。