Observe unread count
Returns the count of unread messages.
You can get the count of unread messages for the current user.
This API returns a LiveData
of type Int
and will notify your app if the count changes. See the Android developer docs to learn more about LiveData.
Sample use case
- Show a badge in your app with the number of unread messages for your user.
Option #1: Observe directly in the UI Component
Kustomer.getInstance().observeUnreadCount().observe(viewLifecycleOwner) {
Log.i(TAG, "unread count = $it")
})
Option #2: Observe through use of a ViewModel
val unreadCount = liveData{
emitSource(Kustomer.getInstance().observeUnreadCount())
}
viewModel.unreadCount.observe(viewLifecycleOwner) {
Log.i(TAG, "unread count = $it")
})
Updated about 1 year ago