Get Unread Conversation Count
Fetches the count of unread conversations for group chatrooms and direct message (DM) chatrooms. The response includes the number of unread conversations in each type, which can be used to display notification badges or unread indicators.
Steps to get unread conversation count
- Call the
getUnreadConversationsCount()
function using the instance ofLMChatClient
. - Process the response
LMResponse<GetUnreadConversationsCountResponse>
to handle the unread counts or any errors.
// Fetch unread conversation counts using LMChatClient
let response = LMChatClient.shared.getUnreadConversationsCount()
if response.success, let unreadCounts = response.data {
print("Unread group chatroom conversations: \(unreadCounts.unreadGroupChatroomConversations)")
print("Unread DM chatroom conversations: \(unreadCounts.unreadDMChatroomConversations)")
} else {
print("Error fetching unread conversation counts: \(response.errorMessage ?? "Unknown error")")
}
Models
GetUnreadConversationsCountResponse
Represents the response model containing unread conversation counts for different chatroom types.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
unreadGroupChatroomConversations | Int | Number of unread conversations in group chatrooms | |
unreadDMChatroomConversations | Int | Number of unread conversations in direct message chatrooms |