ServicePattern / MobileAPI_Android

Messaging API library and example for Android mobile platform
1 stars 1 forks source link

Duplicate messages in chat events #27

Closed bramley-stride closed 3 years ago

bramley-stride commented 3 years ago

Same as iOS issue: https://github.com/ServicePattern/MobileAPI_IOS/issues/31 Sometimes apps are getting duplicate events so duplicated messages in chat window. It's not happening every time. image image

ALobastov commented 3 years ago

We cannot investigate the issue without logs. Please provide full client logs (debug output from Android Studio or xCode).

ALobastov commented 3 years ago

Please close once same iOS issue is resolved (https://github.com/ServicePattern/MobileAPI_IOS/issues/31).

Seems the server is fine, but the app uses async event polling and getChatHistory() concurrently and renders the events twice (one from polling and once from getChatHistory response).

Just to clarify. The main way of getting server events is polling. It started by calling ContacCenterCommunicator.startPolling(chatID). The library will poll for event and deliver them to the application via chatSessionEvents callback.

Alternatively, there is a ContactCenterCommunicator.getChatHistory() method which would return the entire history of the current chat session. This history shows all events, including the ones which have been previously delivered via callback. Therefore it is application's responsibility to avoid double rendering of the same event received via callback and via getChatHistory().