title: Determine background status with SwiftUI
body: <p>When using SwiftUI with iOS 13+, the <strong>traditional means of determining background state no longer work</strong>. For example:</p>
  <ul>
  <li><p>AppDelegate methods <code>applicationDidEnterBackground(_ application: UIApplication)</code> and <code>applicationDidBecomeActive(_ application: UIApplication)</code> do not get called.</p>
  </li>
  <li><p>Notifications <code>didEnterBackgroundNotification</code>, <code>willEnterForegroundNotification</code>, <code>didBecomeActiveNotification</code> and <code>willResignActiveNotification</code> do not get sent.</p>
  </li>
  </ul>
  <p>As an alternative, there are <code>UIWindowSceneDelegate</code> callbacks: <code>sceneDidBecomeActive(_ scene: UIScene)</code>, <code>sceneWillResignActive(_ scene: UIScene)</code>, <code>sceneWillEnterForeground(_ scene: UIScene)</code>, <code>sceneDidEnterBackground(_ scene: UIScene)</code></p>
  <p>The problem with these replacements is that they are specific to one of multiple scenes that are entering and leaving the foreground.  They do not provide a simple and clean way to determine if the entire app is in the foreground or background.</p>
  <p><strong>Determining app foreground/background status is important for reasons that have nothing to do with the user interface.</strong>  Some iOS features fail silently when the app is not in the foreground (wildcard bluetooth scanning and iBeacon transmission are two examples.)  I often develop iOS frameworks that have no user interface whatsoever, so <strong>I need a way to determine app background/foreground state that does not rely on pasting a bunch of boilerplate code in the <code>UIWindowSceneDelegate</code></strong> -- it is not reasonable for me to ask somebody using my framework to do that.</p>
  <p>Are there any straightforward ways to determine the apps's foreground/background status on iOS 13 with SwiftUI?</p>