iOS进入后台后不久会自动将其暂停.您需要让iOS知道您将继续在后台运行.
iOS pauses your app automatically shortly after it goes into the background. You need to let iOS know that you are going to continue operating in the background.
在项目>选项> 版本信息 ,您可以将需要在后台继续运行的服务的字符串值添加到数组键UIBackgroundModes
中.它将添加到您在iOS上的项目的 info.plist 中.
In Project > Options > Version Info you can add to the array key UIBackgroundModes
the string values for the services that require to continue running in the background. This gets added to the info.plist for your project on iOS.
您可以查阅
You can consult Apple's documentation on what these values do . . .
- 值-说明
- 音频-该应用会在
背景.
- 位置-该应用程序可向您提供基于位置的信息
用户,并要求使用标准位置服务(例如
反对重大变更位置服务)来实现这一目标
特征.
- 语音-该应用提供了IP语音服务.具有此功能的应用
系统启动后,密钥会自动启动,因此该应用程序可以
重新建立VoIP服务.具有此密钥的应用程序也被允许
播放背景音频.
- 获取-该应用需要来自以下内容的新内容:
定期建立网络.如果方便的话,
系统在后台启动或恢复该应用,并为其提供一个
少量时间下载任何新内容.这个值是
在iOS 7.0和更高版本中受支持.
- 远程通知-该应用使用
远程通知,以表明有新内容可用
下载.当远程通知到达时,系统启动
或在后台恢复该应用,并为其提供少量
是时候下载新内容了. iOS 7.0支持此值
然后.
- 报摊内容-该应用处理的内容
最近使用报亭工具包在后台下载
框架,以便在用户需要时准备好内容.这
iOS 5.0及更高版本支持该值.
- 外部附件-该应用
与定期传送数据的附件通信
间隔. iOS 5.0及更高版本支持此值.
- bluetooth-central -该应用程序使用CoreBluetooth框架来
在后台与蓝牙配件通信.这
iOS 5.0及更高版本支持该值.
- 蓝牙外围设备-该应用
使用CoreBluetooth框架在外围模式下进行通信
带有蓝牙配件.系统将提醒用户注意
具有此密钥集的应用程序潜在的隐私隐含意义.看到***的
维护用户隐私的做法,以获取更多信息
隐私. iOS 6.0及更高版本支持此值.
-
Value - Description
-
audio - The app plays audible content in the
background.
-
location - The app provides location-based information to
the user and requires the use of the standard location services (as
opposed to the significant change location service) to implement this
feature.
-
voip - The app provides Voice-over-IP services. Apps with this
key are automatically launched after system boot so that the app can
reestablish VoIP services. Apps with this key are also allowed to
play background audio.
-
fetch - The app requires new content from the
network on a regular basis. When it is convenient to do so, the
system launches or resumes the app in the background and gives it a
small amount of time to download any new content. This value is
supported in iOS 7.0 and later.
-
remote-notification - The app uses
remote notifications as a signal that there is new content available
for download. When a remote notification arrives, the system launches
or resumes the app in the background and gives it a small amount of
time to download the new content. This value is supported in iOS 7.0
and later.
-
newsstand-content - The app processes content that was
recently downloaded in the background using the Newsstand Kit
framework, so that the content is ready when the user wants it. This
value is supported in iOS 5.0 and later.
-
external-accessory - The app
communicates with an accessory that delivers data at regular
intervals. This value is supported in iOS 5.0 and later.
-
bluetooth-central - The app uses the CoreBluetooth framework to
communicate with a Bluetooth accessory while in the background. This
value is supported in iOS 5.0 and later.
-
bluetooth-peripheral - The app
uses the CoreBluetooth framework to communicate in peripheral mode
with a Bluetooth accessory. The system will alert the user to the
potential privacy implications of apps with this key set. See Best
Practices for Maintaining User Privacy for more information on
privacy. This value is supported in iOS 6.0 and later.
请注意,您实际上需要选择与您正在执行的操作相匹配的模式.当您真正要做的只是后台处理时,您不能仅选择提取.
Notice you need to actually select the mode that matches what you are doing. You can't just select fetch when really all you are doing is background processing.