ios - 后台获取不工作

标签 ios swift background-fetch

我在使后台提取工作时遇到问题。请参阅下面的代码。我在 info.plist 中添加了 fetch 作为后台模式。我使用 Debug -> Simulate background fetch 模拟提取。 控制台日志中没有任何输出。我很快就找不到任何好的例子。有谁知道如何让它工作?

func application(application: UIApplication!, performFetchWithCompletionHandler
        completionHandler: ((UIBackgroundFetchResult) -> Void)!) {

println("Background fetch occured!");
completionHandler(UIBackgroundFetchResult.NewData)
}

最佳答案

我整个早上都在为这个问题而战,但我有一个不幸的解决方案:

根据 Xcode 6 发行说明中的​​“Known Issues”部分:

The Xcode menu command Simulator Background Fetch does not work.
Use the menu command in iOS Simulator instead. (20145602)

问题是模拟器中没有选项来触发它。

我已经测试过了,它仍然是 Xcode 6.3.1 中的一个问题

关于ios - 后台获取不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27281562/

相关文章:

swift - 应用程序在后台获取的 Collectionview 的 reloadData() 处崩溃

ios - 仅禁用模拟器的应用程序传输安全

ios - 在 swift2.1 中以编程方式使用 topLayoutGuide

swift - 我想循环遍历集群注释中的所有注释

swift - 从 View 之外的函数访问@StateObject

ios - 突然出现许多 Fabric Out of Memory session : Can Fabric OOM Reports ever be false alarms?

ios - 确保收到的推送通知是针对正确的用户

iOS 相机 View 间歇性地以黑色打开

ios - Swift NSDate 格式化程序问题

ios - UIApplication 应用状态返回错误值