# 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.<br>

### 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**

<table><thead><tr><th width="247.125">Deprecated Methods</th><th width="272.52734375">Replacement</th><th>Notes</th></tr></thead><tbody><tr><td><strong>client</strong>.<strong>enableUnreadCount()</strong> </td><td>-</td><td>Must be removed</td></tr><tr><td><strong>client</strong>.<strong>observeUserUnread() or client.getUserUnread()</strong></td><td><strong>channelRepository</strong>.<strong>getTotalChannelsUnread()</strong></td><td>Has the same return type</td></tr></tbody></table>

**Models**

<table><thead><tr><th width="294.5234375">Deprecated property</th><th width="225.65234375">Replacement</th><th>Notes</th></tr></thead><tbody><tr><td><strong>channel.subchannelsUnreadCount</strong></td><td><strong>channel.unreadCount</strong></td><td>Replace with a new property</td></tr></tbody></table>

### 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.&#x20;
* **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.&#x20;
  * Refer to this documentation: [Total unread count of all channels](https://docs.social.plus/social-plus-sdk/chat/channels/unread-count/channel-unread-count#total-unread-count-of-all-channels)&#x20;
* **channel.unreadCount**
  * Replace any use of `channel.subChannelsUnreadCount` with `channel.unreadCount` to read the unread count for that specific channel.&#x20;
  * Refer to this documentation: [Channel unread count](https://docs.social.plus/social-plus-sdk/chat/channels/unread-count/channel-unread-count#channel-unread-count)&#x20;

### Breaking Behavior&#x20;

* **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.&#x20;
* **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.&#x20;

### Migration Steps

1. **Remove `enableUnreadCount()`**\
   Delete any calls to `client.enableUnreadCount()`, as this method is no longer supported and has been fully deprecated.&#x20;
2. **Replace `observeUserUnread()`  or `getUserUnread()`with `getTotalChannelsUnread()`**\
   Instead of subscribing to `observeUserUnread()`, switch to [`getTotalChannelsUnread()`](https://docs.social.plus/social-plus-sdk/chat/channels/unread-count/channel-unread-count#total-unread-count-of-all-channels) 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()`](https://docs.social.plus/social-plus-sdk/chat/channels/query-channels) before calling `getTotalChannelsUnread()`.&#x20;
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/developers/migration-guides/sdk-v7-unread-count-migration-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
