# Posted API and Websocket API for mobile app

**URL:** <https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408>\
**Category:** Mobile Apps\
**Created:** [September 13, 2020, 8:32am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408 "2020-09-13T08:32:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxakak1998](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/maxakak1998/32/4115_2.png) [@maxakak1998](https://forum.mattermost.com/u/maxakak1998)\
**Post date:** [September 13, 2020, 8:32am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/1 "2020-09-13T08:32:49Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [September 14, 2020, 12:09pm UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/2 "2020-09-14T12:09:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maxakak1998](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/maxakak1998/32/4115_2.png) [@maxakak1998](https://forum.mattermost.com/u/maxakak1998)\
**Post date:** [September 15, 2020, 2:27am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/3 "2020-09-15T02:27:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maxakak1998](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/maxakak1998/32/4115_2.png) [@maxakak1998](https://forum.mattermost.com/u/maxakak1998)\
**Post date:** [September 16, 2020, 12:01am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/4 "2020-09-16T00:01:27Z")

</div>

Please reply me as soon as possible

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [September 16, 2020, 4:17pm UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/5 "2020-09-16T16:17:05Z")

</div>

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](https://community-release.mattermost.com/core/channels/peer-to-peer-help) and one of our community members may be able to help with this.

---

<div class="post-metadata">

**Author:** ![maxakak1998](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/maxakak1998/32/4115_2.png) [@maxakak1998](https://forum.mattermost.com/u/maxakak1998)\
**Post date:** [September 17, 2020, 3:18am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/6 "2020-09-17T03:18:56Z")

</div>

Thanks ! Hope it is fast

---

<div class="post-metadata">

**Author:** ![maxakak1998](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/maxakak1998/32/4115_2.png) [@maxakak1998](https://forum.mattermost.com/u/maxakak1998)\
**Post date:** [September 21, 2020, 8:56am UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/7 "2020-09-21T08:56:52Z")

</div>

Have you got any responses from your team yet ?

---

<div class="post-metadata">

**Author:** ![streamer45](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/streamer45/32/4133_2.png) [@streamer45](https://forum.mattermost.com/u/streamer45)\
**Post date:** [September 21, 2020, 5:29pm UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/8 "2020-09-21T17:29:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [September 21, 2020, 11:11pm UTC](https://forum.mattermost.com/t/posted-api-and-websocket-api-for-mobile-app/10408/9 "2020-09-21T23:11:27Z")

</div>

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

- [Websocket handler](https://github.com/mattermost/mattermost-mobile/blob/master/app/actions/websocket/index.ts#L302)
- [Redux action](https://github.com/mattermost/mattermost-mobile/blob/master/app/actions/websocket/posts.ts#L31)
- Various reducers that handle `RECEIVED_NEW_POST`
