当我使用Xcode的背景提取模拟时,背景提取有效。但是,当设备未连接到Xcode时,后台提取不会进行大约几个小时的测试。
我启用了功能,我的应用未终止。有什么建议吗?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
return true
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let request = WeatherRequest(url: weatherUrl(for: "city"))
request.perform{result in
// show data in view controller
completionHandler(.newData)
}
}