Hi I am working in chat base application by using Twilio Programming chat in android But facing a strange issue .I have bottom navigation where i display Total Unread count of chat and chat listing where user see individual unread count of each chat.When User click individual unread chat then unread count is reset to zero which work perfectly but when i return back to chat listing and suddenly new message receive then chat listing screen is updated to new message but its unread count is zero.Where as total notification count of bottom navigation is work properly.After few second when new message again receive then its individual count is receive and work perfectly
The Problem is when user return to chat listing and new message receive within two or three seconds then unread count return null or zero after 10 or more seconds unread count of individual chat work perfectly.below is the code sample of individual read count
// indivisual read count get on channel
subscribedChannel.getUnconsumedMessagesCount(object : CallbackListener<Long>() {
override fun onSuccess(count: Long?) {}})
code for total read count of bottom navigation
chatClient!!.channels.getUserChannelsList(object : CallbackListener<Paginator<ChannelDescriptor>>() {
internal var countCustomer: Long = 0
internal var countProvider: Long = 0
override fun onSuccess(channelDescriptorPaginator: Paginator<ChannelDescriptor>) {
for (descriptor in channelDescriptorPaginator.items) {
// if (appPreferences.getBoolean(Common.IS_LOGIN))
val splitData=descriptor.uniqueName.split("_")
// Log.e(TAG,"unique name is "+descriptor.uniqueName)
if (splitData.size==1)
{
if (splitData[0] == session.userId)
{
Log.e(TAG,"unique name is size one"+descriptor.uniqueName)
countCustomer += descriptor.unconsumedMessagesCount
}
}
if (splitData.size==2)
{
if (splitData[0] == session.userId || splitData[1] == session.userId)
{
countCustomer += descriptor.unconsumedMessagesCount
if (descriptor.unconsumedMessagesCount>0)
{
Log.e(TAG,"unique name is size two "+descriptor.uniqueName)
}
}
}
//if (appPreferences.getBoolean(Common.IS_LOGIN_PROVIDER))
/* if (descriptor.uniqueName.split("_")[1].equals(session.userId))
countProvider += descriptor.unconsumedMessagesCount*/
}
if (channelDescriptorPaginator.hasNextPage())
channelDescriptorPaginator.requestNextPage(this)
else {
val twilioCountData = TwilioCountData(countCustomer, countProvider)
e.onSuccess(twilioCountData)
}
}
})
I also attach use case video in below link https://gofile.io/d/yF8qNP.Any Help Would be appreciable thanks