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
});
Source: stackoverflow.com
Related Query
- How to send data to database with user account from Firebase?
- How to properly store data from Firebase Realtime Database and render it with React once it has been retrieved?
- How to send data from dialog back to parent container with react?
- How to improve firebase real time database rules with anonymous user
- how to fetch data from firebase realtime database in react js
- How fetch data from firebase realtime database in react js
- How can I get the right data from database with react
- How can I send information from one user to another using Firebase realtime database?
- how to save the data from firebase I recently Created with axios and react?
- React with firebase cloud firestore- presenting data from the database
- I want to send the data from a request form to a database in the MySQL workbench from a javascript file in a ReactJs project, but I have no idea how
- How to get a single data element from the database with Redux and React?
- how to send data From one component to another components with context in react?
- How to send data from a form data to a database using ReactJS , Node.js and MySQL queries?
- how to fetch data without reloading the page from firebase database in reactjs
- How to retrieve a data from API or Firebase before rendering anything to the user in React?
- How to compare current user id with the id from one collection in firebase using React
- How to get the data from firebase realtime database in react js?
- How Can I Send an Authentication Token to Expressjs from React with Firebase Auth
- How to utilize useEffect hooks to fetch data from Firebase RealTime Database
- How to get data from firebase with an array of indexes? React/Node.js
- How to write and read real-time data from Firebase with React js
- Add user data to database with firebase (React) (Google authentication)
- How to send data from list into form with React?
- How to send user data and its profile image using POST request from axios api to Django Rest Framework?
- How to use inline image src with data coming from database in react.js?
- (ReactJs) How do I read user data from firebase authentication users?
- How to send text area data with formatting to a database and retrieve it the same way
- How can I find a value of a state variable in React js when data is retrieved from Firebase database
- Losing data properties from firebase realtime database user collection
More Query from same tag
- Waiting for Ajax Call before Setting Initial State in React/Redux
- AWS Cognito/React.js newPasswordRequired Challenge
- !important on makeStyle
- ES6 best way to import React's named imports
- Nothing was returned from render error in React application when embedding a functional component and returning list from there
- React: Component with just a form, form submit action differs depending on consumer of the component
- Universal Reactjs with Nashorn and Tomcat
- Dynamic Route with react/axios, nodejs/express
- Super expression must either be null or a function (Custom Marker)
- React datepicker styling
- Import default react component with two or more different name
- Functional Component to display input fields
- ReactJS how to always show only certain number of array items
- How to change All Styles in Navbar after actions
- How do I make the invalid hook call go away?
- how can i access the history in my react components from props?
- Background Image Style is not working in react
- Make some filters on an array then unfilter with an "All" filter
- How to make React Material grid responsive?
- react-redux connect() function mapStateToProps is updating but component not re-rendering
- How to Nesting React Components with JSON data
- How to target a ref inside a component from another component?
- Alternative collecting checkbox value using push pull of lodash
- Open NavBar on button click
- Reactjs (javascript) how do I not see that the list is empty (Before) api gets called
- React router v4 wildcard next to index route
- React init state array with init function that repeatedly calls setState
- Typescript Redux - Type Checking with Parameter Props from Dispatch Props
- React: 2 way binding props
- Weird behavior on array map after state update