Create new Ode in Firebase

Asked

Viewed 472 times

1

I’m developing an Android chat room app using Firebase. The current structure is as follows (being Assedio, Beauty etc rooms):

Estrutura atual

To date, user data is being stored with the Firebase standard, com.google.firebase.auth.FirebaseUser;, but now I need to save a new data for each user: a nickname which shall be defined only once and cannot be modified.

In this question recommended to create a user Node and save the nickname in it... But I’m having a hard time understanding this part of creating Ode and saving/modifying the data. I believe it is simple, but I’ve read the references of Firebase and I’m not able to implement.

I would appreciate it if someone could explain in detail or recommend material about it.

The code is in a Github repository, and the chunk with the creation of each room is in this filing cabinet.

1 answer

1


As already said, you can create a new Ode, for example: "users" and within it put all the necessary information about each user, for example: username, email, photourl, token and etc...

For security reasons, set the access rules for this Node in firebase-Realtime-database in the "rules" tab and add the permissions for this Node, 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 google authentication, shown in the sample project below, in the auth folder: https://github.com/firebase/quickstart-android

Based on the data received after authentication, save them to the Node "users", something like the one shown below:

inserir a descrição da imagem aqui

I don’t know if this information is what you were looking for, but if you need more detail, let us know in the comments that I see if I can better detail the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.