Reputation: 69
I am using the Pre-built Firebase UI authentication for my swift project. The goal is to present the authentication page when the user clicks on the "user profile" button. Otherwise, the user doesn't have to register or sign in.
I have initialized a navigationController. So my initial thought was to simply push the Auth controller to my navigationController.
self.navigationController?.pushViewController(authUI.authViewController(), animated: true)
It failed with the error that no nested navigation controller is allowed as the authViewController()
will return an instance of the initial navigation view controller of AuthUI.
My second thought was to simply call Window and set the rootViewController as the authViewController
. Then just use the authViewController
as the new navigation controller
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = authUI.authViewController()()
Unfortunately, it failed. Nothing showed up but a black screen.
The only way I figured is to call
self.present(authUI.authViewController(), animated: true, completion: nil)
However, the screen will be shown separately, which is not really what I want (see below)
Any thoughts/ideas/ suggestions are greatly appreciated.
Upvotes: 0
Views: 208
Reputation: 299
I hope this can help you.
let authVC = authUI.authViewController()
authVC.modalPresentationStyle = .fullScreen
self.present(authVC, animated: true, completion: nil)
Thanks.
Upvotes: 1