title: How to push a view controller from App Delegate on didReceiveRemoteNotification in Swift?
body: <p>I can't find any definitive answer to this and I'm starting to struggle. The closest I have got so far is to <code>present</code> the desired view controller but obviously that displays it modally and not with the tab bar or nav bar.</p>
  
  <p>I have in my <code>AppDelegate</code> the <code>didReceiveRemoteNotification</code> function to try and handle Firebase push notifications. Essentially I'd like to able auto-segue to a specific view controller in my app, based on the key-value pair I assign on the Firebase console.</p>
  
  <p>So far, my App Delegate looks like this:</p>
  
  <h1>AppDelegate</h1>
  
  <pre><code>    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) {
  
          let info = userInfo as NSDictionary
          let name: String = info.value(forKey: "view-controller") as! String
  
      switch name {
      case "controller1":
          print("controller1")
          let storyBoard = UIStoryboard.getMainStoryboard().instantiateInitialViewController()
          UIApplication.shared.delegate!.window!!.rootViewController = storyBoard
          DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
              print("Time now reached")
              let storyboard = UIStoryboard(name: "Main", bundle: nil)
              let controller1VC = storyboard.instantiateViewController(withIdentifier: "controller1VC") as! Controller1VC
              self.window?.rootViewController?.present(controller1VC, animated: true)
          }
      default:
          print("Nothing")
      }
  
  }
  
  // and an extension I have...
  
  extension UIStoryboard {
  public class func getMainStoryboard() -&gt; UIStoryboard {
      return UIStoryboard(name: "Main", bundle: nil)
  }
  }
  </code></pre>
  
  <p>So as you can see I have converted the <code>name</code> to a <code>String</code> so I can handle it then I switch it based on the result. It will instantiate the initial view controller which will always be the MainMenuVC and then after a 5 second delay (this exists purely for testing reasons) I want it to push to Controller1VC.</p>
  
  <h1>AppDelegate or View Controller method?</h1>
  
  <p>Am I on the right lines here? Or should it better to pass the result to the MainMenuVC and implement some logic to then do a <code>performSegue</code> which is comparatively straightforward?</p>
  
  <p>As a sidebar, I am receiving and reading the data absolutely fine from Firebase, I just need to get this to start behaving!</p>
  
  <p>Thank you in advance for any direction you can offer.</p>