I am setting root view controller of my app from below code
let navController = UINavigationController()
//App Theming
navController.navigationBar.barTintColor = Constant.AppColor.navigationColor
navController.navigationBar.tintColor = Constant.AppColor.navigationBarTintColor
navController.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: Constant.AppColor.navigationColorTextColor]
navController.pushViewController(viewContoller, animated: true)
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = navController
appDelegate.window?.makeKeyAndVisible()
Now after I set one controller as root. Then I show alert on the window from below code.
let window = UIApplication.shared.keyWindow!
window.addSubView(mainView)
But the alert does not show up. please let me know what is the issue ? I am not able to understand .
EDIT: On app launch I call the api in app background thread so I get session expire & on session expire I am showing alert to user. So by the time alert is shown & new controller if navigated which hides the alert because new controller is crated .After that I try to show alert then it does not work