title: Swift - How to open specific view controller when push notification received?
body: <p>I got stuck specific view controller is not move when I tap on push notification alert when application is not open stage totally.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) {
      /*
  
      fetch and add push notification data
  
       */
      goAnotherVC()
  }
  
  func goAnotherVC() {
      if (application.applicationState == UIApplicationState.active) {
          /* active stage is working */ 
      } else if (application.applicationState == UIApplicationState.inactive || application.applicationState == UIApplicationState.background) {
          if (type == "1" || type == "2") {
              let storyboard: UIStoryboard = UIStoryboard(name: "MyAppointments", bundle: nil)
              let apptVC = storyboard.instantiateViewController(withIdentifier: "NotificationDetailViewController") as! NotificationDetailViewController
              let navigationController = UINavigationController.init(rootViewController: apptVC)
              self.window?.rootViewController = navigationController
              self.window?.makeKeyAndVisible()
          } else if (type == "3") {
              let storyboard: UIStoryboard = UIStoryboard(name: "MyAppointments", bundle: nil)
              let apptVC = storyboard.instantiateViewController(withIdentifier: "NotificationDetailViewController") as! NotificationDetailViewController
              let navigationController = UINavigationController.init(rootViewController: apptVC)
              self.window?.rootViewController = navigationController
              self.window?.makeKeyAndVisible()
          } else if (type == "4") {
              let storyboard: UIStoryboard = UIStoryboard(name: "Enquiry", bundle: nil)
              let enqVC = storyboard.instantiateViewController(withIdentifier: "EnquiryDetailViewController") as! EnquiryDetailViewController
              let navigationController = UINavigationController.init(rootViewController: enqVC)
              self.window?.rootViewController = navigationController
              self.window?.makeKeyAndVisible()
          }
      }
  }
  </code></pre>
  
  <p>I can get notification and tap to move specific VC when application is active. Please help me what I am missing. </p>