ios7 registerForRemoteNotificationTypes 没有收到请求用户许可的提示

ios7 registerForRemoteNotificationTypes doesn't get prompted to ask the user for permission

当我在 AppDelegate 中设置通知时,尽管我重置了模拟器设置,但仅在 iOS8 下向用户请求许可(我知道远程通知在模拟器中不起作用,但我没有 [=21] 的设备=] 来测试它,但我很惊讶它不要求允许远程通知)。

        if iOS8 {
            println("ios 8")
            let userNotificationTypes: UIUserNotificationType = (UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound)
            let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()
        } else {
            println("ios 7")
            let userNotificationTypes: UIRemoteNotificationType = (UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound)
        application.registerForRemoteNotificationTypes(userNotificationTypes)

        }

这就是我检查 ios7 或 8 哪个有效的方法:

private let iosVersion = NSString(string: Device.systemVersion).doubleValue
let iOS8 = iosVersion >= 8
let iOS7 = iosVersion >= 7 && iosVersion < 8

我也看了这个http://corinnekrych.blogspot.com.es/2014/07/how-to-support-push-notification-for.html

iOS 模拟器不支持推送通知。似乎只是从 iOS 8 开始显示此警报(这并不意味着通知可以与模拟器一起使用)。 See this SO question

所以你得找个设备运行 iOS7,不过你的代码好像不错