I have created my custom alert for logging out of the application but the navigation push is not working. I have also cleared the stack and assigned a new view controller to sign in
Here is my code
try firebaseAuth.signOut()
self.dismiss(animated: true, completion: nil)
let domain = Bundle.main.bundleIdentifier!
UserDefaults.standard.removePersistentDomain(forName: domain)
UserDefaults.standard.synchronize()
print(Array(UserDefaults.standard.dictionaryRepresentation().keys).count)
let controller = storyboard?.instantiateViewController(withIdentifier: "SignInViewController") as! SignInViewController
navigationController?.pushViewController(controller, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.navigationController?.popToRootViewController(animated: true)
}
let signInVC = UINavigationController(rootViewController: controller)
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = signInVC
} catch let signOutError as NSError {
self.dismiss(animated: true, completion: nil)
print("Error signing out: %@", signOutError)
}