title: 3D Touch UIapplicationShortcut doesn't work when app is closed
body: <p>Hi and thanks in advance.</p>
  
  <p>I have an application i wrote that uses the new UIApplicationShortcut's on the home screen using 3D touch.  The shortcuts work once the app is app, but if the app is closed out the shortcuts do not work on the home screen.</p>
  
  <p>When the application is closed the shortcuts launch the app, but the shortcuts do not work, only the application launches.</p>
  
  <p>here is the two methods I use for the shortcuts.</p>
  
  <pre><code>- (void)setupViewControllers {
      // setup the navigation stack
  
      CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
      if (iOSDeviceScreenSize.height == 480)
      {
          _navigationController = (UINavigationController *)self.window.rootViewController;
  
          // iPhone 5 and iPod Touch 5th generation: 4 inch screen
          // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
          UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Main4s" bundle:nil];
  
          UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];
          self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  
          self.window.rootViewController  = initialViewController;
  
          self.myViewController = (ViewController *)_navigationController.topViewController;
          self.myViewController.managedObjectContext = self.managedObjectContext;
  
          [self.window makeKeyAndVisible];
      }
  
      if (iOSDeviceScreenSize.height == 568)
      {
          _navigationController = (UINavigationController *)self.window.rootViewController;
  
          // iPhone 5 and iPod Touch 5th generation: 4 inch screen
          // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
          UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
  
          UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController];
          self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  
          self.window.rootViewController  = initialViewController;
  
          self.myViewController = (ViewController *)_navigationController.topViewController;
          self.myViewController.managedObjectContext = self.managedObjectContext;
  
          [self.window makeKeyAndVisible];
      }
  
      if (self.myViewController){NSLog(@"myViewController is not nil, setupViewControllers");}
      else
      {
          NSLog(@"myViewController is nil, setupViewControllers");//breakpoint inserted here...
      }
  }
  
  - (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
  
      [self setupViewControllers];
  
      // react to shortcut item selections
      NSLog(@"A shortcut item was pressed. It was %@.", shortcutItem.localizedTitle);
      if([shortcutItem.localizedTitle isEqualToString:@"Scan Tag"])
      {
          [self.myViewController toggleScanningTapped:nil];
      }
      if([shortcutItem.localizedTitle isEqualToString:@"Enter Tag"])
      {
          [self.myViewController manualEntry];
      }
      if([shortcutItem.localizedTitle isEqualToString:@"Search for a Tag"]){
          [self.myViewController SearchSwitch];
          [self.myViewController toggleScanningTapped:nil];
      }
      if([shortcutItem.localizedTitle isEqualToString:@"Just Scan &amp; Copy"]){
          [self.myViewController justCopy];
      }
  
      if (self.myViewController){NSLog(@"myViewController is not nil, performActionForShortcutItem");}
      else
      {
          NSLog(@"myViewController is nil, performActionForShortcutItem");
      }
  }
  
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      // Override point for customization after application launch.
  
      [self setupViewControllers];
  
      NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
      if (url != nil &amp;&amp; [url isFileURL]) {
          [self.myViewController handleOpenURL:url];
      }
  
      if (self.myViewController){NSLog(@"myViewController is not nil, didFinishLaunchingWithOptions");}
      else{NSLog(@"myViewController is nil, didFinishLaunchingWithOptions");}
  
      return YES;
  }
  </code></pre>
  
  <p>here is the plist entries...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;array&gt;
      &lt;dict&gt;
          &lt;key&gt;UIApplicationShortcutItemType&lt;/key&gt;
          &lt;string&gt;com.PALIANTech.SUNYScanner.static1&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemTitle&lt;/key&gt;
          &lt;string&gt;Scan Tag&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemSubtitle&lt;/key&gt;
          &lt;string&gt;Add tag to DB&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemIconFile&lt;/key&gt;
          &lt;string&gt;barcode.png&lt;/string&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
          &lt;key&gt;UIApplicationShortcutItemType&lt;/key&gt;
          &lt;string&gt;com.PALIANTech.SUNYScanner.static2&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemTitle&lt;/key&gt;
          &lt;string&gt;Enter Tag&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemSubtitle&lt;/key&gt;
          &lt;string&gt;Manually add tag to DB&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemIconFile&lt;/key&gt;
          &lt;string&gt;ManualEntry.png&lt;/string&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
          &lt;key&gt;UIApplicationShortcutItemType&lt;/key&gt;
          &lt;string&gt;com.PALIANTech.SUNYScanner.static3&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemTitle&lt;/key&gt;
          &lt;string&gt;Search for a Tag&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemSubtitle&lt;/key&gt;
          &lt;string&gt;Scan a tag to search for&lt;/string&gt;
          &lt;key&gt;UIApplicationShortcutItemIconFile&lt;/key&gt;
          &lt;string&gt;search.png&lt;/string&gt;
      &lt;/dict&gt;
  &lt;/array&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>Any help or suggestions would be greatly appreciated.</p>