简体   繁体   English

我们如何在iOS7上后台运行应用程序

[英]How we run the app in the background on iOS7

I want a way to keep my app running in the background and receive location updates. 我想要一种使我的应用程序在后台运行并接收位置更新的方法。 We should be able to detect phone motion and then start data collection in the background as we do in Android. 我们应该能够检测到手机运动,然后像在Android中一样在后台启动数据收集。 My application is a driving application. 我的应用程序是驾驶应用程序。

The app is in the background and executing code. 该应用程序在后台执行代码。 Most apps enter this state briefly on their way to being suspended. 大多数应用在暂停状态下都会短暂进入此状态。 However, an app that requests extra execution time may remain in this state for a period of time. 但是,请求额外执行时间的应用程序可能会在此状态下保留一段时间。 In addition, an app being launched directly into the background enters this state instead of the inactive state. 此外,直接在后台启动的应用会进入此状态,而不是处于非活动状态。 For information about how to execute code while in the background, see “ Background Execution and Multitasking. 有关如何在后台执行代码的信息,请参阅“ 后台执行和多任务处理。

Edited: 编辑:

Support for some types of background execution must be declared in advance by the app that uses them. 对某些类型的后台执行的支持必须由使用它们的应用事先声明。 In Xcode 5 and later, you declare the background modes your app supports from the Capabilities tab of your project settings. 在Xcode 5和更高版本中,您可以从项目设置的“功能”选项卡中声明应用程序支持的后台模式。 Enabling the Background Modes option adds the UIBackgroundModes key to your app's Info.plist file. 启用“后台模式”选项,会将UIBackgroundModes键添加到应用程序的Info.plist文件中。 Selecting one or more checkboxes adds the corresponding background mode values to that key. 选择一个或多个复选框会将相应的背景模式值添加到该键。 Table 3-4 lists the background modes you can specify and the values that Xcode assigns to the UIBackgroundModes key in your app's Info.plist file. 表3-4列出了您可以指定的背景模式以及Xcode分配给应用程序的Info.plist文件中的UIBackgroundModes项的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM