Après avoir créé un utilisateur dans Firebase Auth, faites quelque chose comme ceci :
let newUser = UserItem(uid: < Value >, email: < Value >, login: < Value >, createdDate: < Value >)
// Create a child path with a key set to the uid underneath the "users" node
let refToMainDB = FIRDatabase.database().reference(withPath: "< PathToMainDB >")
refToMainDB.child("users").child(< uid >).setValue(newUser.toAnyObject()
Par exemple, ma structure UserItem :
import Foundation
import FirebaseAuth
import FirebaseDatabase
struct UserItem {
let uid: String
let email: String
let login: String
let bioDescription: String
let nameAndSename: String
let createdDate: String
let ref: FIRDatabaseReference?
init(uid: String, email: String, login: String, bioDescription: String = "", nameAndSename: String = "", createdDate: String) {
self.uid = uid
self.email = email
self.login = login
self.bioDescription = bioDescription
self.nameAndSename = nameAndSename
self.createdDate = createdDate
self.ref = nil
}
init(snapshot: FIRDataSnapshot) {
uid = snapshot.key
let snapshotValue = snapshot.value as! [String: AnyObject]
email = snapshotValue["email"] as! String
login = snapshotValue["login"] as! String
bioDescription = snapshotValue["bioDescription"] as! String
nameAndSename = snapshotValue["nameAndSename"] as! String
createdDate = snapshotValue["createdDate"] as! String
ref = snapshot.ref
}
func toAnyObject() -> Any {
return [
"uid": uid,
"email": email,
"login": login,
"bioDescription": bioDescription,
"nameAndSename": nameAndSename,
"createdDate": createdDate
]
}
}
Vous pouvez consulter mon exemple de code pour cela aquí J'espère que cela vous aidera