【发布时间】:2017-01-28 16:59:33
【问题描述】:
尝试使用 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
}
通过基于操作系统版本号创建 if 语句来执行简单的“修复”并不能解决我的问题。对于 UserNotifications 框架的这个解决方案,我应该做什么或考虑什么?
【问题讨论】:
标签: swift apple-push-notifications firebase-cloud-messaging