Skip to content

Instantly share code, notes, and snippets.

@suraphanL
Last active September 11, 2016 16:41
Show Gist options
  • Save suraphanL/1995737700353cfcf416a0482c2d9392 to your computer and use it in GitHub Desktop.
Save suraphanL/1995737700353cfcf416a0482c2d9392 to your computer and use it in GitHub Desktop.
//Registration
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
// Enable or disable features based on authorization.
}
}
//UNAuthorizationOptions
public struct UNAuthorizationOptions : OptionSet {
public init(rawValue: UInt)
public static var badge: UNAuthorizationOptions { get }
public static var sound: UNAuthorizationOptions { get }
public static var alert: UNAuthorizationOptions { get }
public static var carPlay: UNAuthorizationOptions { get }
}
//Token Registration
UIApplication.shared().registerForRemoteNotifications()
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment