Hello 👋 How can we help?

Display unread messages' count in your iOS app

Use the following method to display the number of unread chat messages in your iOS app.
Written by Konstantine
Updated 1 week ago

In order to display the number of new messages in your application, fetch unread messages from the server. Use once after initializing HelpCrunch SDK:

ObjC:
[HelpCrunch checkUnreadMessages:^(NSUInteger numberOfUnreadMessages) {
  // show a badge somewhere in your application
}];
Swift:
HelpCrunch.checkUnreadMessages { (numberOfUnreadMessages) in
  // show a badge somewhere in your application
}

Initiate every time you want to display the number on unread messages on UI using the following method:

ObjC:
NSUInteger numberOfUnreadMessages = [HelpCrunch numberOfUnreadMessages];
Swift:
let numberOfUnreadMessages = HelpCrunch.numberOfUnreadMessages()

Did this answer your question?