title: iOS check what UIViewContoller is visible from appdelegate
body: <p>I'm switching between view controllers as followed: </p>
  
  <pre><code>ChatWindowViewController *viewController = [[ChatWindowViewController alloc] init];
  [self presentViewController:viewController animated:YES completion:nil];
  </code></pre>
  
  <p>when i receive a push notification i want to know if this view controller is the one on screen now...</p>
  
  <p>I'v tried everything but i seem to be getting it all wrong.</p>
  
  <p>When I try:</p>
  
  <pre><code>UIViewController *cont = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
  
  UIViewController *pVC = self.window.rootViewController.navigationController.visibleViewController;
  
  UIViewController *pVC1 = self.window.rootViewController;
  
         UIViewController *pVC = self.window.rootViewController.navigationController.topViewController;
  </code></pre>
  
  <p>They all return null.</p>
  
  <p>only this one return something..</p>
  
  <pre><code>UIViewController *pVC1 = self.window.rootViewController;
  </code></pre>
  
  <p>but it returns the wrong view controller...</p>
  
  <p>what am i doing wrong here?</p>