Search code examples
iosswiftxcodefirebasejsqmessagesviewcontroller

Swift - How to check if two users are present in JSQMessagesViewController?


We are developing an iOS application which has a chat through JSQMessagesViewController and Firebase. When a message is sent by one user, the other user will receive a notification for the message. However, we desire a functionality where if the other user is in the chat, he should not receive the notification as he can already see all the chat-messages.

What is the best logic / way to implement this desired functionality?

Xcode 8.1, Swift 3, Firebase, JSQMessagesViewController


Solution

  • According to me there are two things that you can do:

    1)You can use observers, like typing , for mapping two users when they are in private chat. Just make a status key on firebase and set it to true if two users are on chat page. In this case just don't send push as probably you are sending it from client end.

    2)Or you can just ignore notifications when application is active when you see that payload has same user with which you are chatting.