Posted API and Websocket API for mobile app

Use case:

  1. Users use mobile app, login and open the public chat channel( Channel A)
  2. Users open chat in the browser and login with the same account they did at the step 1
  3. Users send message to the public chat channel ( Channel A) in the browser.
  4. Users get their message in the both app and web
    Current result: Users cant see the message in their app which they typed in the browser.
    Expected result: Users can see the message in their app which they type in the broswer.

My mobile app has been setting websocket successfully and it is able to get the event “posted” thanks to Websocket API.

But if you log in with the same account in in both app and web, my websocket just got the data with “channel_viewed” event instead of “posted” when I create a new post by calling mattermost/api./v4/posts

The strange thing that when i debug the web, it’s still can get the “posted” event and insead of “channel_viewed” event like my app. Because the web can get the “posted” event so they can get the “message” field and display it on the channel.

Until now, i just can get the message from another person ( not me) with websocket api

What i am doing wrong here ? Please help me !

Thanks in advance !

What Mattermost server version and mobile app version are you on?

1 Like

Mattermost Version: 5.26.1

Database Schema Version: 5.26.0

Database: mysql

Mobile App Version: Android 9.0, Android 10.0+
I am using Flutter to develop

Please reply me as soon as possible

I’ve asked our team to help with this and I’m waiting for feedback.
Optionally you can also post about this on our Peer-to-peer Help channel on our community server and one of our community members may be able to help with this.

1 Like

Thanks ! Hope it is fast

Have you got any responses from your team yet ?

Hi @maxakak1998,

I am unable to reproduce your issue on my end.

In order to help you further we might need a bit more information about how your application is processing the WebSocket events. These are broadcasted to all connected clients who have permissions to receive them so you should be able to receive it if you are logged as the user who’s making the post. Also, the fact that it’s working on the browser suggests that the server is correctly sending the event. Could you try to log in from two different browsers as the same user and verify both can receive the posted event?

Can you also help take a look at the following code on our mobile repo to see how we’re handling the event: