iPhone应用程序,运行的HTTP请求,而应用程序在后台 [英] iPhone app, running http requests while application in background

查看:146
本文介绍了iPhone应用程序,运行的HTTP请求,而应用程序在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序,我想运行多个查询时
应用是在背景。
我已经使用ASIHtt prequest作出查询,工作正常,但
现在我试图找到一种方式来触发它们的背景。
在应用程序的委托,我已经加入到方法的调用发出请求:

In my iPhone app I would like to run several queries when the application is in background. I already use ASIHttpRequest to make the queries, that works fine but now I try to find a way to trigger them in background. In the app delegate, I have added a call to the method making the request:

[个体经营getItemsFromServer]

   [self getItemsFromServer]

getItemsFromServer运行的异步请求(在模拟器上我
看到这种方法的日志一旦我找回申请,
前景)。
我如何使用某种类型的计时器有这种方法运行,每10
分钟(我只需要运行4或5次,而不是每次10分钟,直到
它可以追溯到前景:-))?

getItemsFromServer runs an asynchronous request (on the simulator I saw the log of this methods once I get back the application to the foreground). How can I use some kind of timer to have this method ran every 10 minutes (I just need to run it 4 or 5 times, not each 10 minutes until it goes back to foreground :-) )?

非常感谢,

最好的问候,

吕克

推荐答案

iOS4的允许您的应用程序的时间X数量,理所当然地认为,iOS4的授予你,你要求的时间执行。退房:<一href=\"http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW6\"相对=nofollow>在后台完成一个长期运行的任务。

iOS4 allows your app to run for X amount of time, granted that iOS4 grants you the time you request. Check out: Completing a Long-Running Task in the Background.

即,

它被暂停之前任何时候,应用程序可以调用beginBackgroundTaskWithExpirationHandler:法向系统提供额外的时间来完成在后台一些长期运行的任务。如果请求被批准,如果应用程序进入后台,而任务过程中,系统将允许进行的额外时间量的应用程序运行,而不是中止它

Any time before it is suspended, an application can call the beginBackgroundTaskWithExpirationHandler: method to ask the system for extra time to complete some long-running task in the background. If the request is granted, and if the application goes into the background while the task is in progress, the system lets the application run for an additional amount of time instead of suspending it

这篇关于iPhone应用程序,运行的HTTP请求,而应用程序在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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