如何而iPhone应用程序在后台运行的异步接收网络消息 [英] How to receive async network message while the iphone app is running in background

查看:127
本文介绍了如何而iPhone应用程序在后台运行的异步接收网络消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPhone应用程序从服务器接收网络消息。当应用程序在前台运行它即可。

I have an iphone app receiving network message from server. It is ok when the app is running in frontend.

然而,当应用程序在后台运行,应用程序不会收到网络消息。我把它之后回到frondend,它开始接收。

However, when the app is running in background, the app does not receive network message. After I bring it back to frondend, it starts receiving.

如何使应用程序可以接收网络消息,即使它在后台运行?

How to make the app can receive network message even it is running in background?

感谢。

推荐答案

首先检查这个帖子:<一href=\"http://stackoverflow.com/questions/4594348/iphone-connecting-to-server-in-background/4594735#4594735\">iphone - 连接到后台服务器

二,具体来说,当你的应用程序是在后台由操作系统冻结,这将无法访问互联网,因此任何呼叫从一个异步请求,后面会不会被你的应用程序审理。

Second, specifically speaking, when you app is in the background and is frozen by the OS, it won't have access to the internet, thus any call back from an async request won't be heard by your app.

三,可能的策略:


  • 当你的应用程序是切换到后台,立即发布到你的服务器的请求,以便您的服务器将有关于应用程序的最新状态更新记录

  • 当你的应用是要切换回前台,再次让你的服务器知道这张贴的要求

  • 这可能发生,你的应用程序仍然在后台,而你的服务器只需要访问或发送任何信息给它。在这种情况下,尝试通过苹果提供的APN(苹果推送通知服务)。它是免费的,易于实施。可能的结果,一旦你设置的APN为您的应用程序会是这样,用户从服务器获取推送消息,然后决定把你的应用程序回到前台。虽然它仍然完全取决于用户,有很好的机会。

这篇关于如何而iPhone应用程序在后台运行的异步接收网络消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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