Skip to content

Instantly share code, notes, and snippets.

@MarksCode
Created April 25, 2017 03:32
Show Gist options
  • Save MarksCode/e20eb0d6e1492cd54f4ae8a84abb341c to your computer and use it in GitHub Desktop.
Save MarksCode/e20eb0d6e1492cd54f4ae8a84abb341c to your computer and use it in GitHub Desktop.
In my iPhone app's home screen I need to check whether the user is logged in or not. In my `viewDidAppear()` I check like this:
override func viewDidAppear(_ animated: Bool) {
if let user = FIRAuth.auth()?.currentUser {
// user is logged in
} else {
// user not logged in, send to home page
self.performSegue(withIdentifier: "NotLoggedInSegue", sender: self)
}
}
In every example online I see people using `FIRAuth.auth()?.addStateDidChangeListener` in their code. If my app's only authentication is through gmail, do I need that or is the way I'm checking if the user is logged in fine?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment