Hello all,
Trying to get a user name from firebase and then displayed on a label.
Any help?
heres a sample of the code.
Thanks in advance
Trying to get a user name from firebase and then displayed on a label.
Any help?
heres a sample of the code.
Thanks in advance
Code Block import UIKit import Firebase class HomeViewController: UIViewController { @IBOutlet weak var userName: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } func getUserName(_ message:String) { let uid = Auth.auth().currentUser?.uid Database.database().reference().child("users").child(uid!).observeSingleEvent(of: .value, with: { (snapshot) in if let dictionary = snapshot.value as? [String: AnyObject] { self.userName.text = dictionary["firstname"] as? String } }) } }