简体   繁体   English

如何使服务器将处理后的数据发送回调用iPhone?

[英]How to make a server send a processed data back to the invoking iPhone?

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. 首先,我在iPhone上有一个应用程序,它将允许用户将数据上传到服务器。 We simply use php to allow the user to upload the data. 我们仅使用php来允许用户上传数据。 Secondly, the server will process this data and then return the processed data back to this iPhone. 其次,服务器将处理此数据,然后将处理后的数据返回给此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?" 我的问题是“如何使服务器将处理后的数据发送回调用iPhone?” Are there some sort of "listening to server" method in iPhone SDK or there are other ways to consider? iPhone SDK中是否存在某种“侦听服务器”方法或其他方法可以考虑? In the case of some errors in connection, is it possible for the server to know which iPhone to send the data back to? 如果连接出现错误,服务器是否可能知道将数据发送回哪个iPhone?

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. iPhone能够发出HTTP请求,因为您必须将数据发送到服务器上的PHP应用程序。 In the HTTP response is where you'll put the processed data. 在HTTP响应中,您将放置已处理的数据。 You'll want to look at The URL Loading System doc for info on how to use it. 您需要查看“ URL加载系统”文档,以获取有关如何使用它的信息。 The response you get back will be in something like XML or maybe JSON, in which case you can use a 3rd party library. 您返回的响应将采用XML或JSON之类的格式 ,在这种情况下,您可以使用3rd party库。

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. iPhone上没有正在运行的侦听Web服务器,您可以将请求发送到该Web服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM