I created a couple web services for my app as follows.
1. Allows a host device to send its information to the web service and will store it in a sql database.
2. Allows a client device to see all nearby devices based on the information in the sql database.
I want the client to now be able to click one of the devices to connect to, which would then somehow link the two together. The question I have is right now my web services can only send a response to a device’s request. What I want is if the host device maybe presses a button, it will send that info to the web service, which will then send some information to the client who previously connected.
How can I accomplish sending information from a web service to a device that hasn’t requested anything?
Background info:
I am using a php based web service and ASIHTTPRequest to send and receive the information on the iphone side.
In 99% of cases, you’re going to want to use polling. Think of any application that gets messages (email, Words with Friends, whatever). They all call the server and ask “are there any new messages for me?” You’ll have to figure out the right frequency for your application.
In the rare case where you need near realtime communication, then you’ll need to setup your app to run as a server. See here: What classes do I use to make an iPhone act as a server?. Obviously the battery and bandwidth cost of this is much higher.