Reputation: 1832
I have configured my app with Firebase. In my app I have user creation and login methods (using their email and password). I need to create new child in Firebase's Database when a new user is created. How can I do this?
Upvotes: 1
Views: 1537
Reputation: 1375
After you do the FIRAuth.auth()?.createUser
, you can check if the error is nil or not. If it is not, then you know the user has been created, and therefore can add your new child. You can do this by writing:
let uid: String = (FIRAuth.auth()?.currentUser?.uid)!
FIRDatabase.database().reference().child(uid).setValue(arrayOfData)
Therefore, the new node that you create is the user's Firebase ID, and will definitely be unique.
Upvotes: 3