# \`SBUBaseChannelViewController\` bug when calling \`loadChannel(channelUrl:messageListParams:)\`

**URL:** https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868
**Category:** iOS
**Tags:** uikit, ios
**Created:** [February 1, 2022, 12:20am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868 "2022-02-01T00:20:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![GoGo7](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gogo7/32/777_2.png) [@GoGo7](https://community.sendbird.com/u/GoGo7)
#### Post date: [February 1, 2022, 12:20am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/1 "2022-02-01T00:20:31Z")

</div>

When `SBUBaseChannelViewController` is initialized with a certain channel ID and then loads a different channel by calling `loadChannel(channelUrl:messageListParams:)`, the `channelUrl` property is not updated.

This results in a bug where the pending message doesn’t get removed.

The code proceeds as follows:

1. `SBUPendingMessageManager.shared.upsertPendingMessage` is called with `baseChannel.channelUrl`

> <https://github.com/sendbird/sendbird-uikit-ios/blob/cef91825d0000718fee11cc18242a3026c829152/Sources/View/Channel/SBUBaseChannelViewController.swift#L989-L992>

1. Subsequent calls to `SBUPendingMessageManager` are called with `channelUrl`.

> <https://github.com/sendbird/sendbird-uikit-ios/blob/cef91825d0000718fee11cc18242a3026c829152/Sources/View/Channel/SBUBaseChannelViewController.swift#L580-L583>

> <https://github.com/sendbird/sendbird-uikit-ios/blob/cef91825d0000718fee11cc18242a3026c829152/Sources/View/Channel/SBUBaseChannelViewController.swift#L571-L574>

I confirmed that the first insert to `SBUBaseChannelViewController.pendingMessages` is called with the correct channel ID whereas later calls for the pending status and success status are called with the initial channel ID.

Please let me know when this gets fixed.

---

<div class="post-metadata">

### Author: ![GoGo7](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gogo7/32/777_2.png) [@GoGo7](https://community.sendbird.com/u/GoGo7)
#### Post date: [February 1, 2022, 10:48pm UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/2 "2022-02-01T22:48:34Z")

</div>

I was able to confirm that things work as they should when calling `viewController.setValue(id, forKey: "channelUrl")` in conjunction with `loadChannel`

---

<div class="post-metadata">

### Author: ![GoGo7](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gogo7/32/777_2.png) [@GoGo7](https://community.sendbird.com/u/GoGo7)
#### Post date: [March 12, 2022, 6:23am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/3 "2022-03-12T06:23:21Z")

</div>

Wondering if anyone has looked into this issue… 🙄

---

<div class="post-metadata">

### Author: ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)
#### Post date: [March 15, 2022, 6:28am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/4 "2022-03-15T06:28:12Z")

</div>

Hi @GoGo7  
Sorry for too late checking your problem.  
**ChannelViewController was not originally designed to change channels internally.**  
But through the loadChannel function, it should be able to the process you want.  
And thanks to your information I found a problem that the logic of not updating the channelURL.  
I will fix this problem in the new version. However, the regular distribution schedule is in two weeks.  
Can you wait for the distribution?

---

<div class="post-metadata">

### Author: ![GoGo7](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/gogo7/32/777_2.png) [@GoGo7](https://community.sendbird.com/u/GoGo7)
#### Post date: [March 20, 2022, 2:23am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/5 "2022-03-20T02:23:53Z")

</div>

Sounds good. Thank you.

---

<div class="post-metadata">

### Author: ![Tez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tez/32/146_2.png) [@Tez](https://community.sendbird.com/u/Tez)
#### Post date: [March 29, 2022, 5:03am UTC](https://community.sendbird.com/t/sbubasechannelviewcontroller-bug-when-calling-loadchannel-channelurl/3868/6 "2022-03-29T05:03:12Z")

</div>

@GoGo7

Regarding this issue, iOS released version 2.2.6 yesterday (Mar, 28th)

- [Release v2.2.6 · sendbird/sendbird-uikit-ios · GitHub](https://github.com/sendbird/sendbird-uikit-ios/releases/tag/v2.2.6)
- [Release v2.2.6 · sendbird/sendbird-uikit-ios-spm · GitHub](https://github.com/sendbird/sendbird-uikit-ios-spm/releases/tag/v2.2.6) (Swift Package)
