Skip to content

Instantly share code, notes, and snippets.

@zontan
Created July 6, 2020 17:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zontan/42513570ba4513c12561f637146d15e3 to your computer and use it in GitHub Desktop.
var handle: AuthStateDidChangeListenerHandle?
var currentUser: User?
override func viewWillAppear(_ animated: Bool) {
handle = Auth.auth().addStateDidChangeListener { (auth, user) in
self.currentUser = user
if user == nil {
self.showFUIAuthScreen()
}
}
}
override func viewWillDisappear(_ animated: Bool) {
if let handle = handle {
Auth.auth().removeStateDidChangeListener(handle)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment