title: Using BGTaskScheduler API with new iOS 14 App. How to register tasks without an AppDelegate?
body: <p>I'm using the BGTaskScheduler API to register background tasks in my iOS 14 app which is using the new App as <code>@Main</code> instead of an <code>AppDelegate</code>.  I thought we were to use <code>scenePhase</code> as below to mimic the previous function of didFinishLaunching in AppDelegate but the below causes a crash: <code>*** Assertion failure in -[BGTaskScheduler _unsafe_registerForTaskWithIdentifier:usingQueue:launchHandler:], BGTaskScheduler.m:185 2020-12-01 12:53:40.645091-0500 newFitnessApp[13487:1952133] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'All launch handlers must be registered before application finishes launching'</code> How to implement BGTaskScheduler?</p>
  <pre><code>@main
  struct newFitnessAppApp: App {
      
      @Environment(\.scenePhase) var scenePhase
      
      //Launch Count (for requesting reviews and to show tutorial)
      //var launchCount = UserDefaults.standard.integer(forKey: TrackerConstants.launchCountKey)
      //var testMode = true
      //@Environment(\.scenePhase) private var phase
      let trackerDataStore = TrackerDataStore(workoutLoader: HealthKitWorkoutLoader())
      
      var body: some Scene {
          WindowGroup {
              AppRootView().environmentObject(trackerDataStore)
          }
          .onChange(of: scenePhase) { newScenePhase in
              switch newScenePhase {
              case .active:
                  print(&quot;App is active&quot;)
                  registerBackgroundTasks()
  </code></pre>