Tracking unread messages in your app enhances user engagement by providing timely notifications.

How it works

  • When a user receives a new message, the SDK triggers an event with the updated unread message count.
  • You can listen for these events using an event listener. See Events.
  • You can also query the SDK at any time to retrieve the current unread message count.

Get unread message count

Retrieve the total number of unread messages:

Kotlin

zendesk.messaging.getUnreadMessageCount()

Java

zendesk.getMessaging().getUnreadMessageCount();

Retrieve the unread message count for a specific conversation:

Kotlin

zendesk.messaging.getUnreadMessageCount(conversationId)

Java

zendesk.getMessaging().getUnreadMessageCount(conversationId);

Listen for unread message changes

To respond to changes in unread messages (for example update a badge or send a notification), add an event listener to your Zendesk SDK instance. See Events for setup instructions and code samples.

For a working example, see the Unread Message Demo App.