Is it Ok to use HTTP REST API for Chat application?

后端 未结 5 592
眼角桃花
眼角桃花 2020-12-23 17:24

We are building a chat application in Android. We are thinking of using HTTP REST API to send outbound messages. Wanted to know if its a good approach or has any downsides c

5条回答
  •  [愿得一人]
    2020-12-23 18:20

    It depends. Do you consider your application to be "live chat"? Do you require a presence indicator, or typing indicator? Features such as those require continuous connection. But there's another set of chat applications that you'd describe as "in-app messaging" enabled. These applications store conversations and conversation lists on some sort of backend; just install the app on another device and log in, and you'll see your conversations on this type of app. These apps don't have any presence indicator, or feeling of liveness.

    Although I haven't implemented any applications with XMPP, it looks like as far as message persistence, the most persistence you'll find with XMPP (out of the box) is persist-until-delivered, similar to SMS. Perhaps you could build a storage/recovery mechanism for XMPP by capturing stanzas as they pass through and storing them in your own DB. But if you don't need the full "chat" experience, using a database, HTTP service and push notifications (to notify of updated threads) seems like a solid path for apps with messaging functionality — which I intend to implement in an iOS & Android app of my own right now.

    Let me know if you've found any good open-source schemas/API design for this.

提交回复
热议问题