我使用的代码来自:aviary sdk
我正在运行Xcode 7.1,而我正在使用的代码会出现多个错误。
错误是;二元运算符“|”不能应用于两个UIRemoteNotificationType,远程通知注册仅适用于iOS 8或更高版本。
以下是代码行:
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 = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
application.registerForRemoteNotificationTypes(types)
}