How to disconnect from a channel?

Using multiple devices in both iOS 15.3.1 and 14.8.1, In a group channel, I have noticed that messages are being marked as read even after dismissing the SBUChannelViewController. Only until the user connects to another channel or closes the app entirely will new messages not be instantly marked as read.

I’ve explored the deepest parts of the iOS SDK and UIKit framework documentation but was unable to find anything related to disconnecting, even force disconnecting from a chat; All I could find was leaving chats entirely and banning a user which isn’t exactly what I’m after.

I have not added any code to my app that relates to automating the reading/marking as read, I do have a class that is listening to the SBDChannelDelegate constantly but that isn’t doing anything more than notifying my managing containers to update themselves with the recent changes (assuming the group channel classes aren’t dynamic, haven’t seen code that said otherwise).
the channel delegate functionality is literally this:

extension GroupChannelsManager: SBDChannelDelegate {

    func channelWasChanged(_ sender: SBDBaseChannel) {
        addChannel(sender, withOverride: true)
    }

    func channelWasDeleted(_ channelUrl: String, channelType: SBDChannelType) {
        if channelType == .group {
            self.channels.removeAll { channel in
                channel.channelUrl == channelUrl
            }
        }
    }

    func channelWasFrozen(_ sender: SBDBaseChannel) {
        addChannel(sender, withOverride: true)
    }

    func channelWasUnfrozen(_ sender: SBDBaseChannel) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, createdMetaData: [String: String]?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, updatedMetaData: [String: String]?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, deletedMetaDataKeys: [String]?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, createdMetaCounters: [String: NSNumber]?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, updatedMetaCounters: [String: NSNumber]?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, deletedMetaCountersKeys: [String]?) {
        addChannel(sender, withOverride: true)
    }

    func channelWasHidden(_ sender: SBDGroupChannel) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDGroupChannel, didReceiveInvitation invitees: [SBDUser]?, inviter: SBDUser?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDGroupChannel, didDeclineInvitation invitee: SBDUser, inviter: SBDUser?) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDGroupChannel, userDidJoin user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDGroupChannel, userDidLeave user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, userWasMuted user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, userWasUnmuted user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, userWasBanned user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channel(_ sender: SBDBaseChannel, userWasUnbanned user: SBDUser) {
        addChannel(sender, withOverride: true)
    }

    func channelDidChangeMemberCount(_ channels: [SBDGroupChannel]) {
        addChannels(channels, withOverride: true)
    }
}

Other than this class, and a generic facade class that manages interaction with the UIKit framework and SDK, there is nothing that I’ve written that would have changed the expected functionality.

Is there a secret function or something I’m not correctly calling? Seeing as we aren’t dismissing via the dismiss button provided by the UIKit (though I looked into the source code and my code underneath looks almost identical, but works with our app structure)

Hi @BeauA,

Can you pelase share the SendBird SDK version that you are currently using with your project so that we can check and investigate further. Meanwhile if you have any other questions please let us know.

Best,
Dhaval.

Hi @Dhaval_Patel,

SendBird SDK: 3.1.5
UIKit Framework: was 2.2.3, updated to 2.2.4 today, still same issue but the change to using the Photo framework wouldn’t likely fix the problem.

Hi @BeauA,

Thank you for sharing the info. I will run some tests on my end with the same SDK and UIKit versions and let you know my findings. Meanwhile, if you have any other questions please let us know.

Best,
Dhaval.

Hi @BeauA,

I tried building the sample project with UIKit 2.3.3 & iOS SDK 3.1.5 but was not able to replicate the instant-read marked issue. Messages are only marked read when the receiver actually opens the chat. Please check the attached screen recording for more details. You can find a sample app that I used for the test here:GitHub - sendbird/sendbird-uikit-ios at v2.2.3.

Please let us know if you have any further questions regarding the UIKit sample app.

Best,
Dhaval.