SDK v7 Unread count Migration guide

SDK v7 brings a revamped unread-count API that computes aggregate and per-channel counts from local cache rather than relying on realtime device synchronization, and deprecates several methods to streamline your integration. In this guide, you’ll learn which methods to remove, what to use instead, how the new behavior may affect your app.

Deprecation Summary

SDK versions

The change takes effect on the following SDK versions.

  • iOS SDK 7.10

  • Android SDK 7.1.0

  • TS SDK 7.2.0

  • Flutter SDK 7.0.0

Methods

Deprecated Methods
Replacement
Notes

client.enableUnreadCount()

-

Must be removed

client.observeUserUnread() or client.getUserUnread()

channelRepository.getTotalChannelsUnread()

Has the same return type

Models

Deprecated property
Replacement
Notes

channel.subchannelsUnreadCount

channel.unreadCount

Replace with a new property

Deprecations

  • enableUnreadCount() is no longer required or supported to activate the unread-count feature. It will be removed in the upcoming version.

  • observeUserUnread() or getUserUnread() has been deprecated and will be removed. This method previously emitted realtime updates of the total unread count across all channels.

  • channel.subChannelsUnreadCount is deprecated and will be removed. It will not provide an accurate unread count of the channel.

Replacements

  • getTotalChannelsUnread()

    • Use this to receive updates of the total unread count across all channels.

    • It computes the sum of unread messages from the channels currently cached in your app.

    • Refer to this documentation: Total unread count of all channels

  • channel.unreadCount

    • Replace any use of channel.subChannelsUnreadCount with channel.unreadCount to read the unread count for that specific channel.

    • Refer to this documentation: Channel unread count

Breaking Behavior

  • No realtime cross-device sync

    • Unlike observeUserUnread(), the new methods do not perform realtime sync across devices. Counts update as soon as the local cache is refreshed.

  • Cache warm-up required

    • To ensure accurate totals, perform a background channel query before calling getTotalChannelsUnread(). Channels loaded in later pages won’t contribute until cached.

Migration Steps

  1. Remove enableUnreadCount() Delete any calls to client.enableUnreadCount(), as this method is no longer supported and has been fully deprecated.

  2. Replace observeUserUnread() or getUserUnread()with getTotalChannelsUnread() Instead of subscribing to observeUserUnread(), switch to getTotalChannelsUnread() which computes the total unread count from cached channels. Depending on your use case, you may need to warm up the cache by querying channels in the background via getChannels() before calling getTotalChannelsUnread().

  3. Switch from channel.subChannelsUnreadCount to channel.unreadCount Access the per-channel unread count directly on the channel object (channel.unreadCount) instead of reading from the deprecated channel.subChannelsUnreadCount.

Reset channel unread count

The markMessageAsRead() function is unchanged. When marking the latest message in the channel as read, the unread count value resets. This value will be recorded both locally and on the server. Other devices shall receive the new update upon the next refresh of the value.

Last updated

Was this helpful?