Xcode 9(iOS 11)向我显示了注册推送(远程)通知时的错误/警告。
这是错误消息
这是代码,我已经尝试过:
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil{
UIApplication.shared.registerForRemoteNotifications()
}
}
错误/警告行:
UIApplication.shared.registerForRemoteNotifications()
如何解决呢?
在swift4
您可以使用以下方法解决此问题
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
希望这会有所帮助...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句