-
-
Save zontan/0f4029095935e919c77b8a33dfddf7fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userRef: DatabaseReference! | |
var resultsArray = [[String:String]]() | |
var handle: AuthStateDidChangeListenerHandle? | |
var currentUser: User? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
userRef = Database.database().reference(withPath: "users") | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
handle = Auth.auth().addStateDidChangeListener { (auth, user) in | |
self.currentUser = user | |
if user == nil { | |
//Handle logout | |
} | |
} | |
} | |
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