I am so new to Firebase (a couple of hours only) and still trying to absorb most of its concepts. I followed the documentation but still found no direct answer to my questio
I am assuming that since you will be having multiple users, you will have them authenticated before they access your app. You may first create a Struct file in Swift, as follows:
import Foundation
import Firebase
struct User {
let uid: String
let email: String
let usermobilenumber : String
let userFirstName: String
let userLastName : String
// Initialize from Firebase
init(authData: FAuthData) {
uid = authData.uid
email = authData.providerData["email"] as! String
userhandle = authData.providerData["userhandle"] as! String
userFirstName = authData.providerData["userFirstName"] as! String
userLastName = authData.providerData["userLastName"] as! String
}
// Initialize from arbitrary data
init(uid: String, email: String, userLastName: String, userFirstName: String, usermobilenumber: String) {
self.uid = uid
self.email = email
self.userLastName = userLastName
self.userFirstName = userFirstName
self.usermobilenumber = userhandle
}
}
Using textfields, perform the user input task. Then, you need to access the Firebase node where you want to write the data (which you may have previously saved as ref = Firebase(url: "my-awesome-app.firebaseio.com/userinfo")
, and simply ref.updateChildValues()
.
My answer is a schematic response to help you get started, because Firebase documentation is quite exhaustive and has answers to most of the questions that a beginner encounters. You should read this website, and go through the API References to help you completely achieve what you want.
Traditionally, you would create a /users node in Firebase that contains any other info you want to store about that user.
Use the uid (user_id) as the node name for each user.
users
uid_0
name: "Bill"
food: "Pizza"
uid_1
name: "Ted"
food: "Tacos"
This question has been asked before so please try searching for questions similar to yours before asking.
A bit more info here Firebase Users Node