Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification.
Here is error message
And here is code, I\'ve tried:<
The error message is pretty clear: dispatch registerForRemoteNotifications to the main thread.
I would use the granted parameter and handle the error accordingly
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
} else {
print(error!)
// handle the error
}
}