iPhone中的应用程序可以永远在后台运行吗?
我知道 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我从您发布的文档中了解到,如果您在 info.plist 中使用
location
值定义UIBackgroundModes
,“系统应该允许应用程序运行根据背景需要”。所以,第一个答案是肯定的,应用程序可以在后台运行,并且它将无限期地运行(直到电池寿命为止)。实际上,这很容易检查。无论如何,在我看来,这种功能是“保留”给类似 GPS 的应用程序的,而且苹果确实很关心它的使用情况:
因此,我知道苹果将非常彻底地筛选所有激活此模式的应用程序,以评估它们是否真的需要持续更新(在这种情况下,该应用程序可能不会被允许进入应用程序商店) 。
现在,为了回答你问题的第二部分,我认为苹果了解你的应用程序是否真正符合规则的一种方法是使用
CLLocationManager
。风险在于,如果你使用其他服务,那么苹果在审查你的应用程序时可能会认为你只需要后台时间,而不需要不断更新位置。但这只是猜测……
As far as I understand from the document you posted, if you define the
UIBackgroundModes
with a value oflocation
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:
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...