-1

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

My Screen looks 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

schema

will be very really thankful if someone could guide me

Hanzala Raza
  • 149
  • 1
  • 16

1 Answers1

1

You just need to implement

    func currentSender() -> SenderType

in your MessagesDataSource to return a struct or class that conforms to SenderType with some ID that identifies the sender in your backend. In your MessageType object, you also need to store the current sender of that message as your SenderType object. (I'm guessing the sender 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 of message.sender vs currentSender(), 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.

Kino Roy
  • 206
  • 2
  • 5
  • thank alot buddy , there is one or two things more which i need to figure out , would you please help me regarding that ? first is Im not getting that navigation bar on the top when i scroll up its getting into safe area as you can see in the first image – Hanzala Raza Jul 25 '20 at 09:50