iPhone中的应用程序可以永远在后台运行吗?

发布于 2024-11-19 14:31:09 字数 495 浏览 2 评论 0原文

我知道 ios 4 可以按照本文档在后台运行应用程序 http://developer.apple.com/ Library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

该文档指出,如果应用程序在后台连续更新用户的当前位置,则可以运行它在后台。但是我们是否必须仅使用 CLLocationManager 来更新当前位置?我们可以使用其他 api(例如 google latitude api)来更新当前位置吗?那么应用程序也有可能永远在后台运行吗?

I know with ios 4 it is possible to run application in background as per this documentation
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html

this documents states that if application updates user's current location in background continuously then it is possible to run it in background.but is it necessary that we have to use only CLLocationManager for updating current location?can we user other apis like google latitude apis for updating current location?then also it is possible that application is able to run in the background forever?

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

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

发布评论

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

评论(1

祁梦 2024-11-26 14:31:09

据我从您发布的文档中了解到,如果您在 info.plist 中使用 location 值定义 UIBackgroundModes ,“系统应该允许应用程序运行根据背景需要”。所以,第一个答案是肯定的,应用程序可以在后台运行,并且它将无限期地运行(直到电池寿命为止)。实际上,这很容易检查。

无论如何,在我看来,这种功能是“保留”给类似 GPS 的应用程序的,而且苹果确实很关心它的使用情况:

对于需要定期获取更精确位置数据的应用程序(例如导航应用程序),您需要将应用程序声明为连续后台应用程序。此选项适用于真正需要它的应用程序,但它是最不理想的选项,因为它会显着增加功耗。

因此,我知道苹果将非常彻底地筛选所有激活此模式的应用程序,以评估它们是否真的需要持续更新(在这种情况下,该应用程序可能不会被允许进入应用程序商店) 。

现在,为了回答你问题的第二部分,我认为苹果了解你的应用程序是否真正符合规则的一种方法是使用CLLocationManager。风险在于,如果你使用其他服务,那么苹果在审查你的应用程序时可能会认为你只需要后台时间,而不需要不断更新位置。

但这只是猜测……

As far as I understand from the document you posted, if you define the UIBackgroundModes with a value of location in your info.plist, "the system should allow the application to run as needed in the background". So, the first answer is yes, the application can run in the background and it will run indefinitely (up to battery life). This could be easily checked, actually.

Anyway, it seems to me that this kind of functionality is "reserved" to GPS-like apps and that Apple is really concerned about its usage:

For applications that require more precise location data at regular intervals, such as navigation applications, you need to declare the application as a continuous background application. This option is available for applications that truly need it, but it is the least desirable option because it increases power usage considerably.

so, I understand that Apple will screen really thoroughly all apps that activate this mode in order to assess if they really need the continuous update or do not (and in this case, possibly, the app would not be let in into the App Store).

Now, to answer the second part of your question, I think that one way that Apple will know if your app really complies with the rules, is its usage of CLLocationManager. The risk is that if you use another service, then Apple could think when reviewing your app that you just need background time without needing to constantly update the location.

But this is just a guess...

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