Observe unread count
Request and show the count of unread messages.
You can request the count of unread messages and also get notified when the count of unread messages changes.
Get unread count
Use getUnreadCount
to get the most recent count of unread messages from the Kustomer servers as an Int.
Kustomer.getUnreadCount { result in
if case .success(let count) = result {
print("\(count) unread messages")
}
}
Get notification for unread count
You can also get notifications for when the unread count changes.
class MyListener:KUSChatListener {
func onUnreadCountChange(count: Int) {
print("Unread count is \(count)")
}
}
let listener = MyListener()
Kustomer.chatProvider.addChatListener(listener)
/// to remove a listener
let listener = MyListener()
var handle = Kustomer.chatProvider.addChatListener(listener)
Kustomer.chatProvider.removeChatListener(handle)
Updated over 2 years ago