Getting local notifications to show while app is in foreground Swift 3
<p>Apparently this is now possible with ios10 :</p>

<pre><code>optional func userNotificationCenter(_ center: UNUserNotificationCenter, 
                 willPresent notification: UNNotification, 
  withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -&gt; Void)
</code></pre>

<p>This answer basically says the tools needed to do it:</p>

<p><a href="https://stackoverflow.com/questions/30852870/displaying-a-stock-ios-notification-banner-when-your-app-is-open-and-in-the-fore/37844312#37844312">Displaying a stock iOS notification banner when your app is open and in the foreground?</a></p>

<p>I'm just not really understanding how to put it all together.</p>

<p>I dont know how important this is, but I'm not able to keep the optional func and xcode wants me to switch it to private. </p>

<p>I'm trying to show the badge, and the docs provide</p>

<pre><code>static var badge: UNNotificationPresentationOptions { get }
</code></pre>

<p>Little lost here. </p>

<p>And then I'm assuming if I want to exclude a certain view controller from getting these badges and I'm not using a navigation controller this code I found would work? :
    var window:UIWindow?</p>

<pre><code>if let viewControllers = window?.rootViewController?.childViewControllers {
for viewController in viewControllers {
    if viewController.isKindOfClass(MyViewControllerClass) {
        print("Found it!!!")
        }
    }
}
</code></pre>