Getting duplicate message in Chat

Hi, Im working on Chat functionality in iOS. Chat support is available in Web, android and iOS.

Im experiencing strange issue. Sometimes when chat is send from iOS it gets duplicated. Duplicated messages can be seen in web as well as in android device when we use it.

In iOS we are fetching the messages and storing it locally and display it. When we try to send the message and if the sendbird connection is not set or ended, we try to establish the connection and after that we send all the messages which are not send to server.
When the app is left idle for sometime or in background for sometime and after that if we try to send a message or attachment, duplicate message issue comes. The same message is send multiple times. This issue is not coming all the time, it’s inconsistant. If we keep on sending the messages, it gets duplicated for sometime.

Can someone help me out here?

Hello @Rohit.Warrier
Thanks for your patient. SDK attempts to send pending messages (that were attempted to be sent while websocket connection is disconnected) when connection is made again.

Would you show me some code snippet and SDK version you use?