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.
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type, pass ConversationType_PRIVATE for one-to-one chat |
| targetId | NSString | Conversation ID |
Get Unread Mentioned Messages in a Conversation
tip
- Versions below 5.2.5 only provide the
getUnreadMentionedMessagesmethod withoutcountanddescparameters, which returns a maximum of 10 messages at a time. - Starting from version 5.2.5,
getUnreadMentionedMessagessupportscountanddescparameters. This method is only available inRCCoreClient. - 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];
| Parameter | Type | Description |
|---|---|---|
| conversationType | RCConversationType | Conversation type |
| targetId | NSString | Conversation ID |
| count | int | Number of messages. Maximum of 100. |
| desc | BOOL | YES: Fetch the latest count messages. NO: Fetch the earliest count messages. |
| completion | Block | Asynchronous callback, returns a list of message objects (RCMessage). |