我试图以这种方式注册本地通知的应用程序:
UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
Run Code Online (Sandbox Code Playgroud)
在Xcode 7和Swift 2.0中 - 我收到错误Binary Operator "|" cannot be applied to two UIUserNotificationType operands.请帮我.
尝试使用Firebase注册远程通知,但是在实现以下代码时,我收到错误:
UNUserNotificationCenter仅适用于iOS 10.0或更高版本
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var soundID: SystemSoundID = 0
let soundFile: String = NSBundle.mainBundle().pathForResource("symphony", ofType: "wav")!
let soundURL: NSURL = NSURL(fileURLWithPath: soundFile)
AudioServicesCreateSystemSoundID(soundURL, &soundID)
AudioServicesPlayAlertSound(soundID)
Fabric.with([Twitter.self])
//Firebase configuration
FIRApp.configure()
//Resource code from stackoverflow to create UNUserNotificationCenter
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
// Enable or disable features based on authorization.
}
application.registerForRemoteNotifications()
return true
}
Run Code Online (Sandbox Code Playgroud)
通过简单的"修复它"不能通过基于操作系统版本号创建if语句来解决我的问题.对于UserNotifications框架,我应该做什么或想到这个解决方案?