iPhone 上使用 Web 服务进行推送与轮询
我正在使用 ASIHttpRequest 库每分钟向 Web 服务请求更新。应用程序接收 json 字符串并解析它。工作正常。
但我想让它更有效......每当有更新时让服务器发送到应用程序信息的最佳方式是什么......而不是不断轮询网络服务?
I'm using the ASIHttpRequest library to ask a web service every minute for updates. The app receives a json string and parses it. It works OK.
But I'd like to make this more efficient.. what would be the best way of getting the server to send to the app info whenever there is an update.. rather than constantly polling the web service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Apple PUSH 通知不是一个好的解决方案
1)你只能向其打包有限数量的数据
2) 可能很难判断用户是否启动了应用程序或退出了应用程序。如果即使用户退出应用程序后仍继续发送 PUSH,他们最终会收到大量垃圾邮件。如果您尝试向服务器发送某些内容以表明用户已关闭应用程序,因此应用程序应停止发送 PUSH,则当应用程序崩溃时,它可能无法工作。
我建议你使用套接字。
或者只是使用计划循环每分钟发出请求。
.....
但我想知道你是否可以只发送一个 PUSH 而不需要警报正文和声音,而只发送一个 0 徽章。如果应用程序打开,它将能够反馈给服务器以继续发送更新。如果没有反馈,则停止发送推送。
Apple PUSH notification is not a good solution
1) You can only package a limited amount of data to it
2) It may be difficult to figure out if users have the app launched, or exited. If you keep sending PUSH even after users exit the app, they will end up with lots of spam. If you try to send something to the server to indicate that users have closed the app so it should stop sending PUSH, it may not work when the app crashes.
I suggest you use Sockets.
Or just use a scheduled loop to make requests every minute.
.....
But I wonder if you can just send a PUSH without alert body and sound, and just sending a 0 badge. If app it opened, it will be able to feedback to the server to continue sending update. If there is no feedback, stop sending push .
Apple 的推送通知可能正是您所寻找的。然而,我相信你需要在网站上实施一些东西来支持他们。我自己没有使用过它们(我还没有深入了解我的应用程序开发),但这里有一个指向它的开发人员文档的链接:
http://developer.apple.com/库/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html
Apple's push notifications may be what you are looking for. However, you'd need to implement something on the website to support them I believe. I haven't used them myself (I haven't gotten that far into my application development), but here is a link to the developer documentation for it:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html
Apple 的 推送通知是一种方式。这是关于 构建推送通知提供程序服务器。
Apple's push notification is one way. Here's a guide on building a push notification provider server.