How to add additional user information in Firebase

I am currently creating an iOS application that has its own Firebase database to handle the main functions of the application. However, I want to add additional information to each user (except for uid, email and password) so that I can check some steps in my application. What is the best way to achieve this, hierarchical? I am using the new Firebase btw.

+4
source share
1 answer

There is really no schema. You write the values ​​to the hierarchy you need. First you refer to the UID.

In Swift, it will be:

var usersRef = ref.childByAppendingPath("users")

, . , .

        let newUser = [
        "provider": authData.provider,
        "displayName": authData.providerData["displayName"] as? NSString as? String
    ]

:

        ref.childByAppendingPath("users")
       .childByAppendingPath(authData.uid).setValue(newUser)

. https://www.firebase.com/docs/ios/guide/user-auth.html

:

{
"users": {
"6d914336-d254-4fdb-8520-68b740e047e4": {
  "displayName": "alanisawesome",
  "provider": "password"
},
"002a448c-30c0-4b87-a16b-f70dfebe3386": {
  "displayName": "gracehop",
  "provider": "password"
  }
}
}

, !

+1

Source: https://habr.com/ru/post/1649218/


All Articles