没有Xcode,后台提取永远不会触发

时间:2019-06-21 10:29:30

标签: ios background-fetch

当我使用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)
    }
}

0 个答案:

没有答案