Php – How to make a server send a processed data back to the invoking iPhone

client-serveriphonenetwork-programmingPHP

I am sorry if the title is unclear. Allow me to elaborate further.

Firstly, I have an application on an iPhone that will allow the user to upload a data to server. We simply use php to allow the user to upload the data.
Secondly, the server will process this data and then return the processed data back to this iPhone. This part is the part that I am still having trouble.

My question is "how to make the server send the processed data back to the invoking iPhone?" Are there some sort of "listening to server" method in iPhone SDK or there are other ways to consider? In the case of some errors in connection, is it possible for the server to know which iPhone to send the data back to?

Best Answer

Well the iPhone is able to make HTTP requests, as you will have to do to send the data to your PHP app on the server. In the HTTP response is where you'll put the processed data. You'll want to look at The URL Loading System doc for info on how to use it. The response you get back will be in something like XML or maybe JSON, in which case you can use a 3rd party library.

If you can't do this in one request - for example if your server side processing takes hours - the only way you'll be able to send the data back is with a Push Notification. There's no listening web server that is running on the iPhone that you would be able to send requests to.

Related Topic