# (iOS)SBSMMessageCollection.fetch doesn't complete

**URL:** <https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458>\
**Category:** iOS\
**Tags:** syncmanager, chatsdk\
**Created:** [June 18, 2020, 5:18pm UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458 "2020-06-18T17:18:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cris\_Warren](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/cris_warren/32/130_2.png) [@Cris\_Warren](https://community.sendbird.com/u/Cris_Warren)\
**Post date:** [June 18, 2020, 5:18pm UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/1 "2020-06-18T17:18:21Z")

</div>

sometimes on a channel when calling `SBSMMessageCollection.fetch ` doesn’t call the completion handler.

```auto
collection.fetch(in: .previous, completionHandler: { (hasMore, error) in
//this completion never gets called... so the fetch for next messages doesn't get called either.
    collection.fetch(in: .next, completionHandler: { (hasMore, error) in
    })
})

```

> **[SyncManager Message Sync | iOS Chat SDK Documentation | Sendbird](https://docs.sendbird.com/ios/sync_manager_message_sync)**
>
> This page provides an overview of how messages can be synchronized by using the SBSMMessageCollection together with other classes. The SBSMMessageCollection is a class that subscribes to message-related events through the...

---

<div class="post-metadata">

**Author:** ![imju](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/imju/32/49_2.png) [@imju](https://community.sendbird.com/u/imju)\
**Post date:** [June 19, 2020, 3:37am UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/2 "2020-06-19T03:37:14Z")

</div>

Can you provide the reproducible steps when fetch doesn’t call the completion handler?

---

<div class="post-metadata">

**Author:** ![Cris\_Warren](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/cris_warren/32/130_2.png) [@Cris\_Warren](https://community.sendbird.com/u/Cris_Warren)\
**Post date:** [June 19, 2020, 2:33pm UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/3 "2020-06-19T14:33:52Z")

</div>

HI imju, sure  
when the user selects the chat, we connect to the channel, initialize the chatViewController and pass the channel object to that controller. then on view did load we initialize the messageCollection as the example on the [SyncManager Message Sync](https://docs.sendbird.com/ios/sync_manager_message_sync) .  
here is a code sample of our view controller. the issue doesn’t happen always, but once it happens on a channel, the issue will always happen on the channel, sometimes after a while it gets fixed on it’s own, sometimes receiving a message on that channel will fix it.

```
var channel : SBDGroupChannel!
var messageCollection: SBSMMessageCollection?
let filter = SBSMMessageFilter(messageType: .all, customType: nil, senderUserIds: nil)
override func viewDidLoad() {
       super.viewDidLoad()
self.messageCollection = SBSMMessageCollection(channel: self.channel, filter: self.filter, viewpointTimestamp: lastSeenAt ?? LONG_LONG_MAX)
self.messageCollection?.delegate = self
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    if !firstVWAppear{
        firstVWAppear = true
            getMessages()
    }
}

func getMessages(){
    self.messageCollection?.fetch(in: .previous, completionHandler: { (hasMore, error) in
    //this completion 👆🏼 never gets called... so the fetch for next messages doesn't get called either.
        self.messageCollection?.fetch(in: .next, completionHandler: { (hasMore, error) in
            // UI Code
        })
    })
}
```

---

<div class="post-metadata">

**Author:** ![imju](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/imju/32/49_2.png) [@imju](https://community.sendbird.com/u/imju)\
**Post date:** [June 23, 2020, 6:33am UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/4 "2020-06-23T06:33:46Z")

</div>

Thanks for the response. Which version are you using? Can you upgrade the sync manager and SDK version to the latest? Please let me know if the issue still comes up and provide the SDK and sync manager version.

---

<div class="post-metadata">

**Author:** ![Cris\_Warren](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/cris_warren/32/130_2.png) [@Cris\_Warren](https://community.sendbird.com/u/Cris_Warren)\
**Post date:** [June 23, 2020, 1:37pm UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/5 "2020-06-23T13:37:46Z")

</div>

HI Imju, thanks for keeping in touch with the issue, I can’t upgrade the sync manager because doing so, causes another bigger issue… [SBSMChannelCollectionDelegate when receiving a new message triggers twice the .update event](https://community.sendbird.com/t/sbsmchannelcollectiondelegate-when-receiving-a-new-message-triggers-twice-the-update-event/427) which hasn’t been solved.  
right now I did update and see there is even a newer version than the one in the attached post but still has the bigger issue… If you could help with this other issue since I haven’t had any more updates on it, or is there any phone number I can contact like engineering support or something…

- SendBirdSDK (3.0.185)
- SendBirdSyncManager (1.1.24):
  - SendBirdSDK (~\> 3.0.178)

---

<div class="post-metadata">

**Author:** ![imju](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/imju/32/49_2.png) [@imju](https://community.sendbird.com/u/imju)\
**Post date:** [June 25, 2020, 7:58pm UTC](https://community.sendbird.com/t/ios-sbsmmessagecollection-fetch-doesnt-complete/458/6 "2020-06-25T19:58:47Z")

</div>

@Cris_Warren I see that you had a previous thread about syncmanager. We cannot reproduce this on our side unfortunately. If you are our customer, you can submit a ticket from your dashboard, then we can continue from there. Let me know.
