【发布时间】:2015-07-27 13:59:28
【问题描述】:
我正在尝试使用 Swift 将解析添加到我的 appDelegate。我收到一个错误提示
无法使用“(UIUserNotificationType)”类型的参数列表调用“registerForRemoteNotifications”
这是我的代码。怎么了?
if application.respondsToSelector("registerUserNotificationSettings:") {
let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
} else {
let types = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
application.registerForRemoteNotifications(types)
}
return true
【问题讨论】:
-
你被写了两次`application.registerForRemoteNotifications(OoO)`,但每次都不同。一个没有 OoO,另一个带有
UIUserNotificationSettings的标志。根据您的消息,最后一个似乎是错误的。似乎你想要:registerForRemoteNotificationTypes(types)(在 else 测试中) -
后者 - 所以 Xcode 说 - 不工作......
-
因为 iOS8 中的类型也发生了变化。之前是
UIRemoteNotificationType而不是UIUserNotificationType=>let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound application.registerForRemoteNotificationTypes(types)}
标签: ios xcode swift parse-platform