Is this normal behavior? insert in SBSMMessageCollection triggers multiple times iOS

when opening a group chat with multiple messages for the first time after app was closed
func collection( _ collection: SBSMMessageCollection, didReceiveEvent action: SBSMMessageEventAction, messages: [SBDBaseMessage]) { switch action { case SBSMMessageEventAction.insert: //👆🏼 this gets triggered 5x times when there is multiple messages. //in this case based on the messages in that SBDGroupChannel the first time it inserts 1 message, second time 15 messages, and 3rd to 5th time 16 messages. } }

@Cris_Warren

It looks like it the documentation, it does state that the insert event could be called multiple times depending on your cache state.

In the above code sample, the collection instance sets the collection delegate to listen to message events and call the fetchSucceededMessage method after initialization. At runtime, according to your caching status, the insert event can return multiple times. The first few events are called to fetch the messages from the local cache. If not enough messages are cached, SyncManager waits until background sync synchronizes with the server before delivering the rest of the messages. Then, you may get more events with those messages.

2 Likes