Skip to content

Instantly share code, notes, and snippets.

@lucianboboc
Created July 13, 2015 18:14
Show Gist options
  • Save lucianboboc/edac5e66b15569a89a1e to your computer and use it in GitHub Desktop.
Save lucianboboc/edac5e66b15569a89a1e to your computer and use it in GitHub Desktop.
func unregisterForNotificationsForApp(){
let application = UIApplication.sharedApplication()
application.unregisterForRemoteNotifications()
NSUserDefaults.standardUserDefaults().setBool(false, forKey: "pushPermissions")
}
func registerForNotificationsForApp(){
let userNotificationTypes = (UIUserNotificationType.Alert |
UIUserNotificationType.Badge |
UIUserNotificationType.Sound);
let device = CurrentDevice()
let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
let application = UIApplication.sharedApplication()
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "pushPermissions")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment