Skip to main content

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

  1. Call the getUnreadConversationsCount() function using the instance of LMChatClient.
  2. 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.

VARIABLETYPEDESCRIPTIONOPTIONAL
unreadGroupChatroomConversationsIntNumber of unread conversations in group chatrooms
unreadDMChatroomConversationsIntNumber of unread conversations in direct message chatrooms