title: Disable push notification for particular VC
body: <p>I am working on chat screen and reciving push notification for chat messages, but I want to disable push when the chat screen for that particular user is open, I have goen through some to the questions but that didn't help</p>
  <p>previous code</p>
  <pre><code>    func userNotificationCenter(_ center: UNUserNotificationCenter,
                              willPresent notification: UNNotification,
                              withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
  completionHandler([.alert, .badge, .sound])
  }
  </code></pre>
  <p>I have tried it to change like this</p>
  <pre><code>    func userNotificationCenter(_ center: UNUserNotificationCenter,
                              willPresent notification: UNNotification,
                              withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {
      let userInfo = notification.request.content.userInfo        
      let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
      
      if var topController = keyWindow?.rootViewController {
          while let presentedViewController = topController.presentedViewController {
              topController = presentedViewController
          }
          
          if let vc = (topController as? UINavigationController)?.viewControllers.last as? MessagesViewController {
              if vc.conversation.id == (userInfo[&quot;gcm.notification.channelID&quot;] as? String) {
                  completionHandler([])
                  return
              }
              else {
                  completionHandler([.alert, .badge, .sound])
              }
          }
          else {
              completionHandler([.alert, .badge, .sound])
          }
      }
      else {
          completionHandler([.alert, .badge, .sound])
      }
  
  }
  </code></pre>
  <p>when ever the notification code it executes the <strong>completionHandler([])</strong> line of code but itdidn't stop push from being visible</p>