I have been trying for some time now to retrieve data from firebase realtime database, but without any luck.
I have a 4 textfield where you can type in userprofile data, and then I store it in the firebase realtime database, using the user.uid, but I do not know how to retrieve the information back to a label for example.
Below is my code for how I store the data. Any ideas on how to retrieve the data? Thanks for any help.
@IBAction func saveAction(_ sender: Any) {
if favTeamTextfield != nil && usernameTextfield != nil && fullNameTextfield != nil && phoneNumberTextfield != nil
{
//Post data to firebase
ref?.child("Users").child((user?.uid)!).setValue(["Full Name": fullNameTextfield.text, "Username": usernameTextfield.text, "Phone Number": phoneNumberTextfield.text, "Favorite Soccer Team": favTeamTextfield.text])
// dismiss the page
presentingViewController?.dismiss(animated: true, completion: nil)
}
else
{
let alertController = UIAlertController(title: "Oops!", message: "Please enter a username to save!", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}