Key Benefit: Provide users with clear visibility into unread messages across individual channels and in aggregate, enabling efficient conversation prioritization and engagement tracking.

Feature Overview

Channel Unread Count enables tracking of unread messages at both individual channel and aggregate levels. This feature provides essential data for chat list interfaces, notification badges, and user engagement analytics.

Individual Channel Tracking

Per-channel unread visibility
  • Real-time unread count updates
  • Channel-specific mention indicators
  • Unread count support detection
  • Live object synchronization

Aggregate Tracking

Cross-channel analytics
  • Total unread count across all channels
  • Global mention status tracking
  • Cached channel aggregation
  • User engagement insights

Implementation Guide

Track unread messages for specific channelsAccess unread count data directly from channel objects to display in chat lists, navigation badges, and conversation headers.

Channel Unread Properties

PropertyTypeDescription
unreadCountNumberNumber of unread messages in the channel
isUnreadCountSupportedBooleanWhether the channel supports unread count tracking
isMentionedBooleanWhether the current user is mentioned in unread messages

Code Examples

// Get unread count from channel object
func displayChannelUnreadCount(channel: AmityChannel) {
    let unreadCount = channel.unreadCount
    print("Channel unread count = \(unreadCount)")
    
    // Update UI with unread count
    updateChannelBadge(count: unreadCount)
    
    // Check if channel supports unread count
    if channel.isUnreadCountSupported {
        showUnreadIndicator(count: unreadCount)
    } else {
        hideUnreadIndicator()
    }
}

// Observe channel for real-time unread updates
func observeChannelUnreadCount(channelId: String) {
    token = channelRepository.getChannel(channelId).observe { liveObject, error in
        guard let channel = liveObject.snapshot else { return }
        
        let unreadCount = channel.unreadCount
        let isMentioned = channel.isMentioned
        
        // Update UI with latest unread data
        DispatchQueue.main.async {
            self.updateUnreadBadge(
                count: unreadCount,
                highlighted: isMentioned
            )
        }
    }
}

// Check unread count support
func checkUnreadSupport(channel: AmityChannel) -> Bool {
    return channel.isUnreadCountSupported
}
Real-time Updates: Channel unread counts are automatically updated through live objects. Subscribe to channel observations to receive instant updates when new messages arrive.

Best Practices

Implementation Strategy: Start with individual channel unread counts in your chat list, then add total unread aggregation for app-level indicators. Always check unread count support before implementing unread-dependent features.