Last active
March 31, 2018 15:55
-
-
Save meyusufdemirci/5593b22f7625bb92aad7f818d0315741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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