For Android, iOS, JS SDK version 6.5.0 and below and TS SDK version v0.0.1-beta.42.3
Reading Status and Unread Count
The ChannelRepository object exposes a totalUnreadCount property that reflects the number of messages that the current user has yet to read. This count is the sum of all the unreadCount channels properties where the user is already a member.
Version 6
The ChannelRepository provides getTotalDefaultSubChannelUnreadCount() method.
Version 5 (Maintained)
The ChannelRepository provides getTotalUnreadCount() method. It's giving the flowable of the number of messages that the current user has yet to read. This count is the sum of all the unreadCount channels properties where the user is a member of.
Unread Mention
To check whether the current user has been mentioned on one of the unread messages:
Version 6
Version 5 (Maintained)
constliveObject=ChannelRepository.getChannel('channelId');liveObject.on('dataUpdated', channel => {// the number of unread messagesconsole.log(channel.unreadCount);});
Version 6
The Channel object exposes a unreadCount property that reflects the number of messages that the current user has yet to read. This count is the sum of all the unreadCount channels properties where the user is already a member. It also provides hasMention which is a boolean presenting having a mention for current user in channel.
The startReading() and stopReading() methods let the server know that the current user is reading a channel. After the startReading()and stopReading() methods are called, the unreadCount is reset to 0.
You can call both methods as much as you'd like, the SDK takes care of multi-device management: therefore a user can read multiple channels, from one or multiple devices at the same time. In case of an abrupt disconnection (whether because the app was killed, or the internet went down, etc.), the SDK backend will automatically call the stopReading on the user's behalf.
Version 6
Version 5 (Maintained)
// start reading a channelawaitChannelRepository.startReading({ channelId:'channel1' });// stop reading a channelawaitChannelRepository.stopReading({ channelId:'channel1' });
Beta (v0.0.1)
This is the legacy feature, for version 6.0.0 and above, please visit Unread Count.