即使已配置正确的背景模式,iOS背景提取也不起作用 [英] iOS Background Fetch Not Working Even Though Correct Background Mode Configured
问题描述
我的应用程序启用了后台获取背景模式并且我验证了plist包含了适当的获取模式。
My app has background modes enabled with Background Fetch checked and I validated the plist includes the appropriate fetch mode.
我还配置了如下间隔:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum);
return true;
}
我已经按如下方式添加了处理程序:
And I have added the handler as follows:
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// Get some new data here
completionHandler(UIBackgroundFetchResult.NewData);
}
我尝试去调试 - >模拟背景提取,但不管它是什么永远不要输入 performFetchWithCompletionHandler
。我还尝试在一个方案下运行应用程序,该方案选中了由于后台获取事件而启动选项。在这个方案下运行只是像往常一样在模拟器中启动应用程序而不调用 performFetchWithCompletionHandler
。
I tried going to Debug->Simulate Background Fetch, but no matter what it never enters the performFetchWithCompletionHandler
. I also tried to run the app under a scheme that has the "Launch due to a background fetch event" option checked. Running under this scheme simply launches the application as usual in the simulator with no call to performFetchWithCompletionHandler
.
任何想法?
谢谢!
编辑:这似乎影响了发布版本我的应用程序也是如此,它可能不会被隔离到模拟器。我正在运行Swift 1.2。
This appears to be affecting the release version of my app as well so it may not be isolated to the simulator. I am running Swift 1.2.
编辑2:我的错误报告刚刚关闭,因为它是另一个错误报告的副本,概述了同样的问题。仍然没有确认该问题与模拟器隔离的信息。
EDIT 2: My bug report was just closed because it is a duplicate of another bug report outlining the same issue. There is still no information confirming the issue is isolated to the simulator.
编辑3:未提及Xcode 6.4 Beta 2中的修复发行说明。 : - (
EDIT 3: No mention of a fix in the Xcode 6.4 Beta 2 release notes. :-(
推荐答案
这是我发现测试背景提取的唯一方法。
Here's the only way I've found to test background fetch.
- 编辑您的计划
- 选择运行
- 选择选项
- 选中由于后台获取事件而启动选项
- 插入iOS设备并在其上运行应用程序。它在iOS模拟器中不起作用。
- Edit your scheme
- Select Run
- Select Options
- Check the "Launch due to background fetch event" option
- Plug-In your iOS Device and run the application on it. It does not work in the iOS Simulator.
这篇关于即使已配置正确的背景模式,iOS背景提取也不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!