Currently unread messages count is 0 and want to get unread messages count for each conversation.
I did used conversation.lastMessageReadIndex but it ask for return results to listener. Don’t know which listener we can use for that?
Currently unread messages count is 0 and want to get unread messages count for each conversation.
I did used conversation.lastMessageReadIndex but it ask for return results to listener. Don’t know which listener we can use for that?
2
Answers
Try this code snippet
I just did this…I don’t know if twilio SDK provides a better way to do this…At least I didn’t find it. I assume this is what you meant by "each conversation", my understanding it’s that you want to find the total unread count of all of your conversations.
Suspend function because getUnreadMessageCount is also suspend, so you have to use this function in a coroutine.
It’s just fetching unread count for each conversation and adding it to the total unread amount if it’s not null. You can also do a ?: 0 to dismiss the if null check