Search code examples
quickblox

What's the more efficient way to build whatsapp like chat functionalities with Quickblox?


What's the more efficient way to build whatsapp-like chat functionalities with Quickblox, in particular these behaviors:

  1. receive a visible/audible notification of a new message from user B while in a chat with user A
  2. update a counter with the number of unread messages
  3. receive a visible/audible notification of a new message while not in a chat (eg, the list of on going conversations)
  4. while in a chat, receive messages from opponent and don't show remote notifications of those same messages

So far, I'm inclined to a solution like this:

  1. use chat rooms for 1:1 chat for the history functionality
  2. register each 1:1 chat room in Custom Objects at the time of creation with meta information including a dateOfLastReceivedMessage field (1 extra call to QB for each user)
  3. every time chatRoomDidReceiveMessage is called, update the date of dateOfLastReceivedMessage field (2 extra calls to QB; search the record and update it)
  4. with every message sent, also send a push notification (1 extra call to QB)
  5. every time didReceivedRemoteNotification is called, compare the date of the message (a) with dateOfLastReceivedMessage in Custom Objects (b) (1 extra call to QB):
    if a > b -> notification is a new/unread message: increment counter of new messages and show a visual clue/play a sound.
    if a > b -> notification is not a new/unread message: do nothing.

For someone familiarized with Quickblox, does this look correct or is there a better way to achieve the same behavior?


Solution

  • 1) use chat rooms for 1:1 chat for the history functionality

    2) register each 1:1 chat room in Custom Objects at the time of creation with meta information including a dateOfLastReceivedMessage field (1 extra call to QB for each user)

    3) every time chatRoomDidReceiveMessage is called, update the date of dateOfLastReceivedMessage field (2 extra calls to QB; search the record and update it)

    You can use 1-1 Chat (not chat room) and also have Chat history, QuickBlox released plugin for this http://quickblox.com/developers/Chat/1:1_Chat_history

    All Chat history will be stored in CustomObjects module. You will be able to use great search API to request chat history

    with every message sent, also send a push notification (1 extra call to QB)

    Correct

    every time didReceivedRemoteNotification is called, compare the date of the message (a) with dateOfLastReceivedMessage in Custom Objects (b) (1 extra call to QB): if a > b -> notification is a new/unread message: increment counter of new messages and show a visual clue/play a sound. if a > b -> notification is not a new/unread message: do nothing.

    Yes, should work this way