title: Add "quick actions" to my iOS 9 app
body: <p>I would like to add the quick actions of iOS 9 to my app.</p>
  
  <p>I put this code in my app delegate:</p>
  
  <pre><code>import UIKit
  enum ShortcutType: String {
      case NewScan = "QuickAction.NewScan"
      case Settings = "QuickAction.Settings"
  }
  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate {
  
      var window: UIWindow?
      static let applicationShortcutUserInfoIconKey = "applicationShortcutUserInfoIconKey"
  
      func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
          UIViewController.prepareInterstitialAds()
  
          if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:"))) {
              UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
          }
  
          // QUICK ACTIONS
              var launchedFromShortCut = false
  
              if #available(iOS 9.0, *) {
                  if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey] as? UIApplicationShortcutItem {
                      launchedFromShortCut = true
                      handleShortCutItem(shortcutItem)
                  }
              } else {
                  return true
              }
              return !launchedFromShortCut
  
      }
  
      /**************** QUICK ACTIONS ****************/
      @available(iOS 9.0, *)
      func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -&gt; Void) {
              let handledShortCutItem = handleShortCutItem(shortcutItem)
              completionHandler(handledShortCutItem)
      }
      @available(iOS 9.0, *)
      func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -&gt; Bool {
          var handled = false
          if let shortcutType = ShortcutType.init(rawValue: shortcutItem.type) {
              let rootNavigationViewController = window!.rootViewController as? UINavigationController
              let rootViewController = rootNavigationViewController?.viewControllers.first as UIViewController?
              rootNavigationViewController?.popToRootViewControllerAnimated(false)
              switch shortcutType {
                  case .NewScan:
  
                      rootViewController?.performSegueWithIdentifier("goToCamera", sender: nil)
                      handled = true
  
                  case.Settings:
                      rootViewController?.performSegueWithIdentifier("goToSettings", sender: nil)
                      handled = true
              }
          }
          return handled
      }
  }
  </code></pre>
  
  <p>Now I can make a force touch on my app icon > quick actions will be shown > I select the Quick Action "New Scan" > the app will open and show me the last view, which I have leave. </p>
  
  <p>But the segue will not be execute. </p>
  
  <p>Here is a part of my storyboard:</p>
  
  <p><a href="https://i.stack.imgur.com/yRArV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yRArV.png" alt="enter image description here"></a></p>
  
  <p>Explanation:</p>
  
  <p>A: Navigation Controller and initiale Controller </p>
  
  <p>B: ViewController, after a check this will make a segue to navigation Controller C</p>
  
  <p>C: Navigation Controller</p>
  
  <p>D: Table View Controller</p>
  
  <p>E: ViewController</p>
  
  <p>If I select New Scan with quick actions - I would like to show ViewController E.</p>