Web服务将信息发送到iPhone [英] Web Service sending information to iPhone

查看:96
本文介绍了Web服务将信息发送到iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的应用程序创建了几个Web服务,如下所示. 1.允许主机设备将其信息发送到Web服务,并将其存储在sql数据库中. 2.允许客户端设备根据sql数据库中的信息查看附近的所有设备.

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.

我希望客户端现在能够单击要连接的设备之一,然后将它们以某种方式链接在一起.我现在的问题是,我的Web服务只能发送对设备请求的响应.我想要的是,如果主机设备可能按下按钮,它将把该信息发送到Web服务,然后Web服务将把一些信息发送到以前连接的客户端.

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.

如何完成从Web服务向没有请求任何内容的设备的信息发送?

How can I accomplish sending information from a web service to a device that hasn't requested anything?

背景信息: 我正在使用基于php的Web服务和ASIHTTPRequest在iPhone端发送和接收信息.

Background info: I am using a php based web service and ASIHTTPRequest to send and receive the information on the iphone side.

推荐答案

在99%的情况下,您将要使用轮询.考虑任何获取消息的应用程序(电子邮件,与朋友交流的单词,等等).他们都呼叫服务器并询问是否有新消息给我?"您必须找出适合您的应用程序的频率.

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.

在极少数情况下,您需要近乎实时的通信,则需要将您的应用程序设置为作为服务器运行.参见此处:做什么类我曾经让iPhone充当服务器吗?.显然,这样做的电池和带宽成本要高得多.

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.

这篇关于Web服务将信息发送到iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆