Um going to demonstrate to you how sending messages can be made…
First you need User UID from Auth and Users collection for ths to work
Pay attention to images below
You can see 2 users, user 2 will send messages to user1.
The user document contains activities, in Ths case, we have messaging activity , so there’s a sub collection of Messages.
Pay attention to the messages collection, we have a document,the documentID is the ID of user2.
It has be like Ths for you to identify the sender . So technically, Ths is saying, the message is from user2 because the message collectionID of Ths documents is from user2.
Now in the messages document, we have sub collection MessageBody. The message body will contain a collection of messages from both user1 and user2
You can see a document here, Ths document contains the message sent by the users, the id of Ths document is automatically generated.
NOTE, ths documents will be created both user1 and user 2 for them to see the message sent and received
Pay attention to the message body, it contains the message and the senderid… The senderid must be included because you want to be able to sort out who sent the message. You can create a logic thats like Ths, if senderid=Logged_In_userID in your app, then align message to left of the screen or right depending on your design…
So If you’re re interested in creating your message activity Ths way, I can help you