So I have a view controller which is dismissed when a user logs in. In the dismiss function completion block I have fired a function which should reload the next view controller. Nothing happens, blank view controller. But if I close the application when I am already logged in, then reopen it, everything loads like it should.
So here is my login function:
func loginFunc() {
if emailField.text != "" && passwordField.text != "" {
Auth.auth().signIn(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
if user != nil {
// Sign In Successful
print("Sign In Sucessful")
self.dismiss(animated: true, completion: {
self.mainVC.starterMethod()
})
} else {
if let myError = error?.localizedDescription {
print(myError)
} else {
print("Error")
}
}
})
}
}
And here is my starterMethod()
:
func starterMethod() {
ref = Database.database().reference()
let userId = Auth.auth().currentUser?.uid
if userId != nil {
print("You are logged in...")
} else {
present(LoginController(), animated: true, completion: nil)
}
setupPicks()
setupViewsMed()
fetchGames()
setNavigationBar()
setupCircles()
}
starterMethod()
is called in the viewDidLoad
I would really like to avoid viewDidAppear()
if possible