Skip to content

Instantly share code, notes, and snippets.

@lucianboboc
Created July 13, 2015 18:14
Show Gist options
  • Select an option

  • Save lucianboboc/edac5e66b15569a89a1e to your computer and use it in GitHub Desktop.

Select an option

Save lucianboboc/edac5e66b15569a89a1e to your computer and use it in GitHub Desktop.

Revisions

  1. lucianboboc created this gist Jul 13, 2015.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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")
    }