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()
如何解决这个问题?
In swift4
你可以用以下方法解决这个问题
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
希望这会有所帮助...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)