0

I've a problem with Firebase. I know how to create an e-mail account with Firebase framework, but I don't know how to send data to my database with an e-mail account.

Example :

You post a comment, and the other users would like to see that.

I already have see the Firebase docs, but they don't say how to send data with an account. Have you a solution for my problem? Thanks in advance.

1 Answers1

0

I'm not sure I understand you correctly. But if you're trying to send messages to other users, you'll typically end up with a database structure that models chat rooms. For 1:1 chat rooms, I recommend using the structure I showed here: Best way to manage Chat channels in Firebase

In code you could then add a message to that room with something like:

let myUid = firebase.auth().currentUser.uid;
let otherUid = "uidOfTheOtherUser"; // This is a value you must 'know" somehow
let chatRoomId = 'chat_'+(myUid<otherUid ? myUid+'_'+otherUid : otherUid+'_'+myUid);

let roomRef = firebase.database().ref(chatRoomId);
roomRef.push({
  text: "This is my message",
  uid: myUid,
  timestamp: firebase.database.ServerValue.TIMESTAMP
});
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807