问题
I use FirebaseUI prebuilt authentication for my swift project. I have two pages/controllers: main and user profile. I have created a navigation controller. When the user profile button is clicked, the login controller will be pushed to the navigation stack.
let loginController = SignInController()
self.navigationController?.pushViewController(loginController, animated: true)
Within the login controller, Firebase UI will be called and popped out from the navigation stack after the login is finished.
DispatchQueue.main.async {
let authVC = authUI.authViewController()
authVC.modalPresentationStyle = .fullScreen
self.present(authVC, animated: true, completion: nil)
self.navigationController?.popViewController(animated: true)}
However, there is a cancel button on the log-in page. I know how to hide it, yet I think a better logic would be returning back to the home page when this button is pressed. The FirebaseUI's documentation doesn't cover how to handle the cancel button.
My first thought was to set the rootController
back to the main page controller if the cancel button is pressed. Yet, obviously, if I call it right after the Auth page is present, the App will go back to the home page without waiting for the user to finish sign-in/sign up
DispatchQueue.main.async {
let authVC = authUI.authViewController()
authVC.modalPresentationStyle = .fullScreen
self.present(authVC, animated: true, completion: nil)
appDelegate?.window.rootController = mainController()
I've also tried to clear the navigation stack, yet it didn't work
Sorry, new to Swift. Any thoughts/advice/suggestions are greatly appreciated.
来源:https://stackoverflow.com/questions/60425050/handle-cancel-button-in-firebaseui-auth-page