I believe that developing an efficient solution to send messages from the server to Devices, in addition to being particularly complex, requires a structure that conventional http does not contemplate. This is definitely not the way you need to go, unless you have some advanced structure like Amazon AWS and plenty of experience.
Mobile developers know this difficulty and have created solutions to solve this issue without driving any developer crazy. On android we have the GCM (Google Cloud Message), that sends messages up to 2kb to the specified device or Devices.
There are many stages to demonstrate here, but the logic is as follows.
- Every android device by default when connecting to the internet has a unique signature registered on google servers.
- When your app registers on your server you log the device signature
- By signing your server creates the message (with a maximum of 2kb) and sends it to the Google GCM servers
- GCM servers have direct access to all connected servers. They therefore send the message to the device.
- The device processes the message that can be complete, or only a connection request to download more complex information.
- If the need exists the device connects again to your server, to complete the operation by downloading for example.
As you can see, these are some necessary steps. Google offers all the documentation for you, but unfortunately not found in Portuguese.
Of course there are other alternatives. Some paid services such as parse.with They solve all server logistics, but there’s a cost to that. There are also some open source solutions that propose to offer a server structure that is already suitable for mobile needs. A project that may have a promising future is the baasbox, but I don’t know how he behaves in a production environment.
Anyway, I hope I helped.
If I’m not mistaken you already had a similar question and a very cool answer, I’ll try to find it for you
– Arubu
found, might help you http://answall.com/questions/113817/technologias-para-app-de-mensagens-instant%C3%A2neas/113867#113867
– Arubu
a form of the client "understand" and is the one I usually see being used is the client continuously identify and "ask" to the server if there are new messages for it, you have created services usually for instant messages are used sockets to keep a single connection, with the Rest Voce will have to open a new connection every time, it will be more expensive
– deFreitas
I understand, I will study then on sockets, but you know if I program through these sockets, and then I want to develop the same application for iOS, it would be possible to make the connection also of the same ?
– Miller Dominguês