I looked at several solutions on SO but none seem to work. I have a problem where when I open and then close an app, it "loads" twice in a row. Is there a way or code to stop this from happening? The app is configured in such a way that when a user closes and then opens the app, the code in the App Delegate sends the app to a "CommandandControlViewController" which devides whether if a user is Signed In, Not Signed In and sends to the appropriate ViewController.
func applicationWillEnterForeground(_ application: UIApplication) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.main.bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let yourVC = mainStoryboard.instantiateViewController(withIdentifier: "CommandAndControlViewController") as! CommandAndControlViewController
appDelegate.window?.rootViewController = yourVC
appDelegate.window?.makeKeyAndVisible()
}