title: How do I open a specific view controller from local notification?
body: <p>On pressing a button on the local notification, I want to be able to open a specific view controller depending on some information in the notification. How can this be done? </p>
  
  <p>In AppDelegate.swift</p>
  
  <pre><code>let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
          UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
  
          if let options = launchOptions {
              if let notification = options[UIApplicationLaunchOptionsLocalNotificationKey] as? UILocalNotification {
                  if let userInfo = notification.userInfo {
                      let type = userInfo["TYPE"] as! String
                      // do something neat here
                      if (type == "SLEEP") {
  
                      } else if (type == "STRESS") {
  
                      } else {
  
                      }
                  }
              }
          }
  
          return true
      }
  </code></pre>
  
  <p>Setting the notifications in one of the view controllers</p>
  
  <pre><code>let sleepInPrefs = prefs.valueForKey(key) as? NSDate
  if sleepInPrefs != nil {
      print(sleepInPrefs)
      print("Setting stress notif")
      for notification in (UIApplication.sharedApplication().scheduledLocalNotifications )! {
          if (notification.userInfo!["TYPE"]) != nil {
              if (notification.userInfo!["TYPE"] as! String == key) {
                  UIApplication.sharedApplication().cancelLocalNotification(notification)
                  print("deleting notif")
                  break
              }
          }
      }
      let notification = UILocalNotification()
      notification.fireDate = sleepInPrefs
      notification.repeatInterval = NSCalendarUnit.Day
      notification.timeZone = NSCalendar.currentCalendar().timeZone
      notification.alertBody = ""
      notification.hasAction = true
      notification.alertAction = "open"
      notification.soundName = UILocalNotificationDefaultSoundName
      notification.userInfo = ["TYPE": key ]
      notification.category = "PROMPT"
      UIApplication.sharedApplication().scheduleLocalNotification(notification)
  }
  </code></pre>