Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save meyusufdemirci/5593b22f7625bb92aad7f818d0315741 to your computer and use it in GitHub Desktop.
Save meyusufdemirci/5593b22f7625bb92aad7f818d0315741 to your computer and use it in GitHub Desktop.
var actionType: String?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if let push = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [String: Any] {
if let notificationDict = push["aps"] as? [String: Any] {
actionType = notificationDict["actionType"] as? String
}
}
if #available(iOS 10, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
guard error == nil else {
return
}
if granted {
DispatchQueue.main.sync(execute: {
application.registerForRemoteNotifications()
})
}
}
application.registerForRemoteNotifications()
} else {
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment