iPhone sdk,在后台运行应用程序并发送频繁的http请求

发布于 2024-10-16 15:21:14 字数 68 浏览 6 评论 0原文

我正在尝试利用 iPhone 4 的多任务处理功能。我想在后台运行应用程序并频繁发送http请求来发送/接收数据,可以吗?

I am trying to take advantage of iPhone 4 multitasking feature. I want to run app in background and frequently send http request to send/receive data, is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云仙小弟 2024-10-23 15:21:14

令人惊讶的是,“多任务”iOS 4.x 中实际上很少进行时间切片。相反,发生的实际上只是应用程序挂起/恢复。当用户点击主页按钮后将应用程序发送到后台时,它将在短时间内停止执行周期 (*)。

(*) 有一些例外情况。声明自己为“VoIP 提供商”的应用程序、基于位置的应用程序和音乐应用程序可以获得后台执行周期,大概只是为了响应相应的事件(例如发生“位置的重大变化”)而执行那些非常具体的操作。一些应用程序显然试图扩展规则并寻找未记录或未充分记录的技术来继续获取后台执行周期。

而Undeadlegion所说的“请求运行时间”是有持续时间限制的。

现实情况是,在iOS4上,应用程序不允许在后台持续运行。

Surprisingly, there is actually very little time-slicing going on in the "multi-tasking" iOS 4.x. What goes on instead is really just application suspend / resume. When an application is sent to the background upon the user tapping the home button, it will stop getting execute cycles after a short while (*).

(*) There are a few exceptions. Applications which declare themselves as "VoIP providers", location-based apps, and music apps can get background execute cycles, presumably only though to perform those very specific operations in response to corresponding events (like a "significant change in location" occurring). Some apps apparently try to stretch the rules and find undocumented or not-strongly-documented techniques to continue getting background execute cycles.

And the "requested running time" that Undeadlegion mentioned is limited in duration.

The reality is that on iOS4, applications are not allowed to run continuously in the background.

故笙诉离歌 2024-10-23 15:21:14

@Undeadlegion 提出了一种实现目标的可行方法。为了更清楚,请查看我之前对类似问题的回答, iphone - 在后台连接到服务器

@Undeadlegion has suggested a plausible way to achieve your goal. To be more clear, take a look at my previous answer to a similar question at SO, iphone - Connecting to server in background

救赎№ 2024-10-23 15:21:14

当您的应用程序处于后台时,可以请求运行时间。

参阅多任务开发人员指南

请 根据您的 http 请求的意图,推送通知可能是一个可行的替代方案。

这可能是必要的,因为您不提供音频、VoIP 或位置服务,因此您的应用程序无法无限期地在后台运行。

It is possible to request running time while your app is backgrounded.

See Multitasking Developer's Guide

Although, depending on the intent of your http requests, push notifications may be a viable alternative.

This may be necessary because you aren't providing audio, voip, or location services, so your app can't run in the background indefinitely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文