Will download resume after closing my app in Background Mode

后端 未结 3 1252
广开言路
广开言路 2020-12-11 18:30

I figured out about it is possible to download in background mode of application. I have implemented Background Fetching Mode in XCode and registered background task and its

3条回答
  •  忘掉有多难
    2020-12-11 18:37

    When any task completes, the NSURLSession object calls the delegate’s URLSession:task:didCompleteWithError: method with either an error object or nil (if the task completed successfully). If the task failed, most apps should retry the request until either the user cancels the download or the server returns an error indicating that the request will never succeed. Your app should not retry immediately, however. Instead, it should use reachability APIs to determine whether the server is reachable, and should make a new request only when it receives a notification that reachability has changed.

    If the download task can be resumed, the NSError object’s userInfo dictionary contains a value for the NSURLSessionDownloadTaskResumeData key. Your app should pass this value to call downloadTaskWithResumeData: or downloadTaskWithResumeData:completionHandler: to create a new download task that continues the existing download.

    If the task cannot be resumed, your app should create a new download task and restart the transaction from the beginning.

    checkout here: Life cycle of URL Session

提交回复
热议问题