Message Receipts

Overview#

Message receipts is a feature which allows users to know the status of the sent messages as well as the delivered and read time for the messages. The chat app users are well informed about the status of the sent messages.

info

To observe message's sent, delivered, read status refer the message callback listeners.

You need to update the ongoing chat user jid always whenever you are entering/exiting the chat window of user by using below method. it is used by sdk internally for receipts.

During the lifecycle of a page, when the page initializes using initState and when the AppLifecycleState transitions to resumed, set the user JID as the ongoing chat user. Subsequently, when the page is disposed and the AppLifecycleState transitions to paused, clear the ongoing chat user.

ArgumentTypeDescription
JIDStringjid of the chat user
@override
void initState() {
super.initState();
Mirrorfly.setOnGoingChatUser(jid: JID);
}
@override
void dispose() {
super.dispose();
Mirrorfly.setOnGoingChatUser(jid: "");
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
// Handle app lifecycle state changes here
switch (state) {
case AppLifecycleState.resumed:
// Page has resumed
Mirrorfly.setOnGoingChatUser(jid: JID);
break;
case AppLifecycleState.paused:
// Page has paused
Mirrorfly.setOnGoingChatUser(jid: "");
break;
}
}

Mark messages as delivered#

You don't need to send the delivery receipts explicitly, it will be automatically sent by the sdk.

Mark messages as read#

Once the user reads the messages of user B or entered into the chat window of user B, you can mark the messages as read by using the below method. In this case user B's jid will be passed to the below method. Then read receipts will be managed by sdk. sdk will utilise the ongoing chat user jid which is set by this method Mirrorfly.setOnGoingChatUser(jid: String)

ArgumentTypeDescription
JIDStringjid of the chat user
Mirrorfly.markAsRead(jid: JID);

Remove unread message separator#

To remove the unread message separator in a chat conversation list call the below method.

Mirrorfly.deleteUnreadMessageSeparatorOfAConversation(jid: JID);
ArgumentTypeDescription
JIDStringJid of the user/group

Mark As Read and Remove unread message separator#

To mark the messages by read and remove the unread message separator in a chat conversation list call the below method.

Mirrorfly.markAsReadDeleteUnreadSeparator(jid: JID);
ArgumentTypeDescription
JIDStringJid of the user/group

Single chat message status#

To get the time of sent, delivered and seen status of a message sent by you in a single one to one chat call the below method.

Mirrorfly.getMessageStatusOf(messageId: messageId).then((value) {
var chatMessageStatusDetail = chatMessageStatusDetailFromJson(value);
});
ArgumentTypeDescription
MESSAGE_IDStringmessage id of the message

Group chat message status#

To get the time delivered and seen status of a message sent by you in a group chat call the below methods.

Group message delivered list#

To get the list of users to whom a message was successfully delivered call the below method.

Mirrorfly.getGroupMessageDeliveredRecipients(messageId: messageId, groupJid: jid, flyCallBack: (FlyResponse response) {
if(response.hasData) {
var items = messageStatusDetailFromJson(response.data);
}
});

Refer this doc to know more about MessageStatusDetail Class

info

Only messages sent by the current user will have the options to get delivered and read list.

ArgumentTypeDescription
MESSAGE_IDStringId of a group message
flyCallbackFlyResponsecallback to observe the action status

Group message read list#

To get the list of users whom are read/seen the message call the below method.

Mirrorfly.getGroupMessageSeenRecipients(messageId: messageId, groupJid: jid, flyCallBack: (FlyResponse response) {
if(response.hasData) {
var items = messageStatusDetailFromJson(response.data);
}
});
info

Only messages sent by the current user will have the options to get delivered and read list.

ArgumentTypeDescription
MESSAGE_IDStringId of a group message
flyCallbackFlyResponsecallback to observe the action status

Mark a conversation as read#

By marking a converstaion as read the unread count will be reset and it is considered the message inside the conversation were read by you.

Mirrorfly.markConversationAsRead(jidList: JID_LIST);
ArgumentTypeDescription
JID_LISTList<String>List of user/group jid

Mark a conversation as unread#

By marking a converstaion as unread it is considered the message inside the conversation were in unread state.

Mirrorfly.markConversationAsUnread(jidList: JID_LIST);
ArgumentTypeDescription
JID_LISTList<String>List of user/group jid
info

The read/unread flag is available as a property in the name of isConversationUnRead in the RecentChat for a user.