Unread Messages
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 observer. See Events.
- You can also query the SDK at any time to retrieve the current unread message count at any time.
Get unread message count
Retrieve the total number of unread messages:
Zendesk.instance?.messaging?.getUnreadMessageCount()
Retrieve the unread message count for a specific conversation:
Zendesk.instance?.messaging?.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 observer to your Zendesk SDK instance. See Events for setup instructions and code samples.
For a working example, see the Unread Message Demo App.