score:0

Accepted answer

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
});

Related Query

More Query from same tag