简体   繁体   中英

Swift Firebase Ios User Defined Child Value

I want to create child id from text input when user register.

how to change chidbyautoid to a user input id

Just use self.ref.child("users").child(user.uid).setValue(["username": fname]) . Replace user.uid with your custom user input.

Try this:

var username = [String:AnyObject]()
username["username"] = usernametextfield!.text  //outlet of username textfield 
var userinput = userinputtextfield!.text       //outlet of input textfield     

self.ref.child("users").child("\(userinputid)").setvalue(username)

self.ref.child("users").child((Auth.auth().currentUser?.uid)!).setValue(["username": fname])

This Works Fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM