After logging out the user, I use the code below after logging in again. The problem is that the application starts duplicated, all messages are duplicated. How to prevent it?
let appDelegate = UIApplication.shared.delegate! as! AppDelegate
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "view_controller_phone")
appDelegate.window?.rootViewController = initialViewController
appDelegate.window?.makeKeyAndVisible()
UIView.transition(with: appDelegate.window!, duration: 1.0, options: .transitionCrossDissolve, animations: nil, completion: nil)