mesibo

Function getUnreadCount is not updated at runtime - Mesibo iOS SDK


In the chat history (summary) page of my app I'm using the function getUnreadCount() on MesiboProfile to get the number of messages currently unread so that I can show an indicator near the message.

The problem is that count is only correct the first time I read the summary from the read session. If it arrives a new message when I already read the summary, that count is not updated.

I saw that the counter gets fixed if I read the summary again but is this the recommended way to update that counter? I'm using the iOS SDK v1.9.55


Solution

  • In 1.x, the unread count can be updated manually. Set the unread count to zero once you read it or increment it every time you receive a new message. This avoids database access. Here is the 1.x code which does the same.

    Update: you can also use getUnreadMessageCount() in the user or group readsession (not the summary session) to get it from the database.

    https://github.com/mesibo/ui-modules-ios/blob/master/Messaging/Messaging/UserListViewController.m#L474

    In 2.x, we have moved this to API with additional logic.