I\'ve built an application for iPhone using Swift and Xcode 6, and the Parse framework to handle services.
While following the Parse tutorials on how to set up push noti
This is method I have written in the code and works fine once it called on launch (didFinishLaunch)
class func registerNotification() {
if #available(iOS 10.0, *) {
// push notifications
UNUserNotificationCenter.current().requestAuthorization(options: [.sound, .alert, .badge]) {
(granted, error) in
if (granted) {
UIApplication.shared.registerForRemoteNotifications()
}
}
let center = UNUserNotificationCenter.current()
center.delegate = AppManager.appDel()
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil {
UIApplication.shared.registerForRemoteNotifications()
}
}
} else {
UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
UIApplication.shared.registerForRemoteNotifications()
}
}