Skip to main content

Get Unread Messages in a Conversation

The IMLib SDK supports retrieving unread messages from a specified conversation, which can meet the needs of jumping to the first unread message or displaying all unread mentions in an app.

Get the First Unread Message in a Conversation

Retrieve the earliest unread message in a conversation.

RCMessage *theFirstUnreadMessage = [[RCIMClient sharedRCIMClient]
getFirstUnreadMessage:ConversationType_PRIVATE
targetId:@"targetId"];

Upon success, the message object (RCMessage) is returned.

ParameterTypeDescription
conversationTypeRCConversationTypeConversation type, pass ConversationType_PRIVATE for one-to-one chat
targetIdNSStringConversation ID

Get Unread Mentioned Messages in a Conversation

tip
  • Versions below 5.2.5 only provide the getUnreadMentionedMessages method without count and desc parameters, which returns a maximum of 10 messages at a time.
  • Starting from version 5.2.5, getUnreadMentionedMessages supports count and desc parameters. This method is only available in RCCoreClient.
  • Starting from version 5.3.0 of RCCoreClient, it is recommended to use the asynchronous result-returning interface below, and the original synchronous interface is deprecated.

Retrieve the earliest or latest unread mentions in a conversation, with a maximum of 100 messages returned.

[[RCCoreClient sharedRCCoreClient]
getUnreadMentionedMessages:ConversationType_PRIVATE
targetId:@"targetId"
count:count
desc: NO
completion:completion];
ParameterTypeDescription
conversationTypeRCConversationTypeConversation type
targetIdNSStringConversation ID
countintNumber of messages. Maximum of 100.
descBOOLYES: Fetch the latest count messages. NO: Fetch the earliest count messages.
completionBlockAsynchronous callback, returns a list of message objects (RCMessage).