Getting Started Guide

Reading Messages & Call History from Database

In this section, we will describe how to read messages from the database.

mesibo provides a set of APIs to read messages and call history stored in the database and sending read receipts. The messages you read will be delivered to Mesibo_onMessage lisetener. You can then use msg.isRealtimeMessage() or msg.isDbMessage() to differentiate between real-time and database message.

To read stored messages from the database, you need to create a read session and set the criteria to read messages; for example,

  • read all messages
  • read call history
  • read messages from a sender
  • read messages for a particular group
  • read messages matching a search query etc.

The read session you create filters the messages in the database based on the criteria provided and gives the resulting list of messages to you.

Reading Modes

There are two modes of operation:

  • Read Messages and call logs. This mode is enabled by default
  • Read Summary (active conversations), read the latest message from each user and group. This allows you to get a snapshot of all the communicating users and groups. You can then create another read session to read messages for any of those users or groups.

Reading Order

Once you set a read session, you can start reading messages by calling read API. You can read messages in the first-in-first-out (FIFO) mode or the last-in-first-out (LIFO) mode. In the first-in-first-out model, the oldest messages are read first. By default, the first-in-first-out mode is disabled.


To read messages and call history for a user or a group

// Read receipts are enabled only when App is set to be in foreground
Mesibo.setAppInForeground(this, 0, true);
MesiboReadSession mReadSession = profile.createReadSession(this);
mReadSession.enableReadReceipt(true);
mReadSession.read(100);

To read the last message from each user and group (summary)

MesiboReadSession mReadSession = MesiboReadSession.createReadSummarySession(this);
mReadSession.enableMissedCalls(mShowMissedCalls);
mReadSession.read(100);

To read messages and call history for a user or a group

// Read receipts are enabled only when App is set to be in foreground
Mesibo.setAppInForeground(this, 0, true)
MesiboReadSession mReadSession = profile.createReadSession(this);
mReadSession.enableReadReceipt(true)
mReadSession.read(100)

To read last message from each user and group (summary)

mReadSession = MesiboReadSession.createReadSummarySession(this)
mReadSession.enableMissedCalls(true)
mReadSession.read(100)

To read messages and call history for a user or a group,

mReadSession = mProfile.createReadSession(self)
mReadSession.enableReadReceipt(true)
mReadSession.read(100)

To read last message from each user and group (summary),

mReadSession = MesiboReadSession.createReadSummarySession(self);
mReadSession.read(100)

To read messages and call history for a user or a group,

MesiboReadSession *mReadSession = [mProfile createReadSession:self];
[mReadSession enableReadReceipt:YES];
[mReadSession read:100];

To read the last message from each user and group (summary),

MesiboReadSession *mReadSession = [MesiboReadSession createReadSummarySession:self];
[mReadSession read:100];

To read messages and call history for a user or a group,

MesiboReadSession rs = profile.createReadSession(this);
rs.read(100);

To read the last message from each user and group (summary),

MesiboReadSession rs = MesiboReadSession.createReadSummarySession(this);
rs.read(100);

Please ensure you are not using a private or incognito browser window when using mesibo. mesibo JavaScript API utilizes IndexedDB for local storage of messages, which does not function in private/incognito browsing modes. For the best experience, use a regular browser window so mesibo can fully leverage browser storage capabilities.

To read messages and call history for a user or a group,

var rs = profile.createReadSession(listener);
rs.enableReadReceipt(true);
rs.read(100);

To read the last message from each user and group (summary),

var summarySession = MesiboReadSession.createReadSummarySession(listener);
summarySession.read(100);

A call to read will return the number of messages read. You can call read on demand. For example, in the case of a messaging app, you only need to show the latest messages on the screen initially. So, first, you can call read(10) to load the last 10 messages. As the user scrolls up the chat history, you can call read again. All subsequent calls to read will read older messages.