【问题标题】:Backgroundfetch for more than 30seconds后台获取超过 30 秒
【发布时间】:2015-10-21 20:16:19
【问题描述】:

我正在开发一个 iOS 应用程序,我必须在其中下载多个 zip 包。 为了处理下载,我使用了一个内部 C++ http-framework。

有没有可能让Background-Fetch 超过 30 秒?

一种可能是使用NSURLSessionNSURLSessionDownloadTask,但http 框架不使用NSURLSession。

另一个解决方案是这个:

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler{}

但这只能工作 30 秒。

但我如何下载Background-Fetch 超过 30 秒的 Zip 文件?

【问题讨论】:

    标签: ios download nsurlsession nsurlsessiondownloadtask background-fetch


    【解决方案1】:

    您可以尝试在您的 didEnterBackground 方法中调用 UIApplication 上的 beginBackgroundTaskWithName:expirationHandler:beginBackgroundTaskWithExpirationHandler: 方法(并在完成后调用 endBackgroundTask ),但这仍然不会让您多花三分钟时间。

    不过,要正确执行,您确实必须使用 NSURLSession。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-02-06
      • 1970-01-01
      • 2021-08-25
      • 2020-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多