1

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?

1

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Ya its Working Thanks For Your Support.
Thank you for this fix - even though I know it is a few years old! :D I am really struggling with then finding the path for a specific index in the array that I have then created! - When I then want my user to be able to edit e.g. his/her nationality, which may be at index 5 in the array created when signing up! Hope the questions makes sense. Thank you :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.