Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift & Firebase - How to store more user data other than email and password?

Tags:

swift

firebase

I'm relatively new to Firebase and trying to develop an app which requires users to give their name and surname in sign up page. But firebase createUserWithEmail method only stores email and password. How can I add this name and surname data to my app and link them with the users? I suppose i need to use FIRStorage but in that way, only options to saving information is saving either from NSData or NSURL, how can I save my name and surname strings?

Thanks in advance!

Edit1: I suppose i was wrong, I need to use real time database rather than storage to save user data. But still I need help. I am coming from Parse and this seems complicated.

like image 839
Atakan Cavuslu Avatar asked Jun 20 '16 16:06

Atakan Cavuslu


People also ask

What is swift?

Swift is a powerful and intuitive programming language for macOS, iOS, watchOS, tvOS and beyond.

What is Swift language used for?

Swift is a powerful and intuitive programming language for macOS, iOS, watchOS and tvOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.

What is swift code ISO 9362?

Swift Code, BIC Code, ISO 9362. BIC sometimes also refers to “Bank Identifier Code”. Swift Code or BIC Code is a unique code to identify financial and non-financial institutions. These codes are mostly used when transferring money between banks, especially for international wire transfers or telegraphic transfer (“TT”).

Why write Swift code?

Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love. Swift code is safe by design, yet also produces software that runs lightning-fast.


1 Answers

Yes, you need to use the realtime database to store your user data. So after creating it you can call the setValue().

FIRAuth.auth()!.createUserWithEmail(email, password: pwd, completion: { authData, error  in
    if error == nil {    
        let userData = ["name": name,
                        "surname ": surname]
        let ref = FIRDatabase.database().reference()
        ref.child('users').child(authData!.uid).setValue(userData)
    } else {
        // handle error
    }
})
like image 87
adolfosrs Avatar answered Sep 26 '22 01:09

adolfosrs