The problem im facing is how can i recognize the sender and reciever of the message ? tried so hard but didn't find any delegate method from which i can separate message and show like chat , right now my msgs are showing like this
the second problem is , I want my msgs on the right side but its appearing on the left side of the screen
My Firebase Schema for Chat
will be very really thankful if someone could guide me
You just need to implement
in your
MessagesDataSource
to return a struct or class that conforms toSenderType
with some ID that identifies the sender in your backend. In yourMessageType
object, you also need to store the current sender of that message as yourSenderType
object. (I'm guessing thesender
variable on your Firebase message schema would work for that?)MessageKit will take care of laying out your cells on the correct side based on the
senderId
ofmessage.sender
vscurrentSender()
, you don't need to do anything explicit other than ensuring the Sender object has the correct senderId for each message, and return the current sender in your MessagesDataSource.