Create new node in Firebase

1

I'm developing an application for chat rooms on Android using Firebase. The current structure is as follows (being Siege, Beauty etc rooms):

Sofar,userdataisbeingstoredwithFirebasedefault,com.google.firebase.auth.FirebaseUser;,butnowIneedtosaveanewdataforeachuser:anicknamethatwillbesetonlyonceandcannotbemodified.

In this question recommended to create a node for user and save the nickname on it ... But I'm having a hard time understanding this part of creating the node and saving / modify the data. I think it's simple, but I've read the Firebase references and I'm not able to implement.

Thank you if anyone can explain in detail or recommend a material about it.

The code is in a Github repository, and the excerpt for each room is in this file .

    
asked by anonymous 13.09.2017 / 16:44

1 answer

1

As already mentioned, you can create a new node, for example: "users" and inside it to put all necessary information about each user, such as username, email, photourl, token and etc ...

For security reasons, define the access rules for this node in the firebase-realtime-database in the "rules" tab and add the permissions of this node, for example:

"users": {
  "$uid": {
    ".write": "auth != null && auth.uid == $uid",
    ".read": "auth != null && auth.uid == $uid"
  }
},

In this case, only the user will be allowed to read and write this information.

As a reference, you can use the google authentication, shown in the sample project below, in the auth folder: link

Based on the data received after authentication, write them to the "users" node, something like the following:

I do not know if this information was what you were looking for, but if you need more detail, please let me know in the comments I see if I can better detail the answer.

    
06.12.2017 / 03:42