似乎没有找到有关registerUserNotificationSettings的更多文档,除了去年11月份(这里)发布的内容。但是,我的旧代码在Xcode 7和Swift 2中似乎不再起作用。
我在AppDelegate中有以下代码:
let endGameAction = UIMutableUserNotificationAction()
endGameAction.identifier = "END_GAME"
endGameAction.title = "End Game"
endGameAction.activationMode = .Background
endGameAction.authenticationRequired = false
endGameAction.destructive = true
let continueGameAction = UIMutableUserNotificationAction()
continueGameAction.identifier = "CONTINUE_GAME"
continueGameAction.title = "Continue"
continueGameAction.activationMode = .Foreground
continueGameAction.authenticationRequired = false
continueGameAction.destructive = false
let restartGameCategory = UIMutableUserNotificationCategory()
restartGameCategory.identifier = "RESTART_CATEGORY"
restartGameCategory.setActions([continueGameAction, endGameAction], forContext: .Default)
restartGameCategory.setActions([endGameAction, continueGameAction], forContext: .Minimal)
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: (NSSet(array: [restartGameCategory])) as Set<NSObject>))
现在我在代码的最后一行收到以下两个错误消息:
'Element.Protocol' 没有名为 'Alert' 的成员
和
无法使用类型为 '(UIUserNotificationSettings)' 的参数列表调用 'registerUserNotificationSettings'
我已经搜索了任何更改的信息,但是我找不到任何东西。 我是否错过了一些显而易见的东西?