Guys, so I researched a lot about this but couldn't reach a conclusion. How does chat app work on Android?
I mean you could use XMPP, SSE or socket. But how long is the connection kept open? And what's is the data flow chart from db to push notifications (FCM) to device?

  • 0
    You can have two parallel communication channels:
    - The actual communication with your server. Do what ever you want.
    - Push/poll to get new messages.

    FCM can do the latter: Either directly notify the user ("here is the message") or notify the app ("there is a message, please wake up and process it").
    In both cases, the message sender uploads it to your application's server, which notifies FCM which notifies the Play Services on the user's device which notifies the app (or you let the Play Services directly display the notification if privacy isn't important).
  • 0
    @sbiewald hey thanks a lot.
    What about the connection on Android device. Do I have to keep socket open always?
  • 0
    @populah No, only while you app is in foreground (and even this is for convenience only, a reconnection can take some time on bad mobile networks) or if the app wakes up for other reasons.
Add Comment