/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Retrieve number of unread items

Copy link

You can retrieve the count of a user's unread messages, unread mentioned messages, or invitations received in group channels and Supergroup channels. You can use this action to display the number of unread items in the UI so that users may check them. This is only available in group channels and Supergroup channels.

To get the count, call the getUnreadItemCount(GroupChannelUnreadItemCountParams, GroupChannelGetUnreadItemCountHandler) method with GroupChannelGetUnreadItemCountHandler.

List of parameters

Copy link
Parameter nameTypeDescription

keys

List[UnreadItemKey]

Specifies the key type to filter the channels with the corresponding type.

customTypesFilter

List?

Specifies the custom channel types to filter channels with the corresponding custom type.

The following table lists some of the properties in UnreadItemKey. To see the comprehensive list of all properties in UnreadItemKey, see the API reference.

Property nameDescription

GROUP_CHANNEL_INVITATION_COUNT

The number of invitations from group channels and Supergroup channels the user has received.

GROUP_CHANNEL_UNREAD_MENTION_COUNT

The number of messages in group channels and Supergroup channels where the user was mentioned but the user hasn't read.

GROUP_CHANNEL_UNREAD_MESSAGE_COUNT

The number of messages in group channels and Supergroup channels the user hasn't read.

NONSUPER_INVITATION_COUNT

The number of invitations from group channels the user has received.

NONSUPER_UNREAD_MENTION_COUNT

The number of messages in group channels where the user was mentioned but the user hasn't read.

NONSUPER_UNREAD_MESSAGE_COUNT

The number of messages in group channels the user hasn't read.

SUPER_INVITATION_COUNT

The number of invitations from Supergroup channels the user has received.

SUPER_UNREAD_MENTION_COUNT

The number of messages in Supergroup channels where the user was mentioned but the user hasn't read.

SUPER_UNREAD_MESSAGE_COUNT

The number of messages in Supergroup channels the user hasn't read.

KotlinKTX
val params = GroupChannelUnreadItemCountParams(
    listOf(
        UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,
        UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT
    ),
    listOf("customType1", "customType2")
)
SendbirdChat.getUnreadItemCount(params) { result, e ->
    if (e != null) {
        // handle error
        return@getUnreadItemCount
    }

    val unreadMentionCount = result?.get(UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT) ?: 0
    val unreadMessageCount = result?.get(UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT) ?: 0
}