Unread Messages
Tracking unread messages in your app enhances user engagement by providing timely notifications.
How it works
- The SDK can call an action event when the unread count changes with the updated unread message count.
- You can get the total number of unread messages for the end user using the
GetUnreadMessageCountAsync()
API.
Get unread message count
The following snippet shows how to retrieve the unread message count:
2.2.1 and below:
UnreadCountResult unreadMessageCountResult = await ZendeskSdk.Instance.Messaging.GetUnreadMessageCountAsync();
2.3.0 and up: Optional parameters:
onUnreadCountChanged
: (Action) Action to be called when the unread count changes shouldSubscribe
: (boolean) Whether to subscribe to the websocket event outside of conversation
The GetUnreadMessageCountAsync
method returns an object of type UnreadCountResult
, which includes an IsSuccess
property indicating whether the operation succeeded. If the operation fails, you can examine the Error
property, an enum of type UnreadCountError
, to understand the cause of the failure.