The unread count for community subchannels is always 0. I’m calling client.enableUnreadCount() after AmityClient is initialised. The total unread count is working fine:
I’m using the open source version of amity for iOS, I’ve tested this on the latest version of the UIKit SDK as well as on the latest beta. My region is set to US
@SocialPlus_Support after investigating this issue it turns out that the unread counter works fine for channels created on iOS side, I pasted the code from the sample app for creating channels and then when I join the channels created on iOS side everything works. It doesn’t work for channels created on backend side. My colleague is going to share his code snippets today to show you how he creates the channels on backend side. We compared channels created on iOS and backend sides in admin panel and found no differences
@SocialPlus_Support No, I have a backend service which is responsible for creating channels and it’s using Amity API api to do so. Here’s a snippet from my colleague who’s responsible for the backend service showing how he creates the channel:
then on the iOS side I’m observing the channels, joining them and the unread counter doesn’t work.
But when I was testing stuff using the sample app you provided then I found out that when I create some dummy channels on iOS side just for testing purposes then the unread counter works.
var token: AmityNotificationToken?
func createChannel() {
if let user = AmityUIKitManager.client.user?.snapshot {
let builder = AmityCommunityChannelBuilder()
builder.setUserIds([user.userId])
builder.setDisplayName("Test channel")
token?.invalidate()
token = channelRepository.getChannel("test-id").observe({ [weak self] (channel, error) in
guard let weakSelf = self else { return }
if error != nil {
weakSelf.createNewCommiunityChannel(builder: builder)
}
})
}
}
private func createNewCommiunityChannel(builder: AmityCommunityChannelBuilder) {
AmityAsyncAwaitTransformer.toCompletionHandler(asyncFunction: channelRepository.createChannel, parameters: builder) { [weak self] channelObject, error in
guard let weakSelf = self else { return }
if let error = error {
print("FAILED \(error)")
}
if let channelId = channelObject?.channelId, let subChannelId = channelObject?.defaultSubChannelId {
print("CHANNEL CREATED")
}
}
}
Can this be caused by the fact that when creating channels on the backend the userIds is not set? Later on I’m joining these channels on iOS side and I verified that the members count is greater than 0 for these channels. Or can you spot any other differences?
Hello @nadol , We have resolved the issue you encountered with the Subchannel Unreadcount. Please verify the fix at your earliest convenience and let us know if there are any further issues.
@nadol After consulting with the team, we recommend updating to version 4.0.0 beta 11, as it already includes the updated SDK version. Updating the SDK separately is not advisable due to performance concerns and the potential for further issues.