When does NSURLSession run?

后端 未结 3 627
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 14:20

I have a situation in which when the device receives a push notification, I would send a NSURLSession combined with a NSURLConnection. I have a couple

3条回答
  •  有刺的猬
    2021-02-09 15:05

    Looks like it's down to you to handle the retry.

    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 is a resumable download task, the NSError object’s userInfo dictionary contains a value for the NSURLSessionDownloadTaskResumeData key. Your app should use reachability APIs to determine when to retry, and should then call downloadTaskWithResumeData: or downloadTaskWithResumeData:completionHandler: to create a new download task to continue that download. Go to step 3 (creating and resuming task objects).

    https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/URLLoadingSystem/NSURLSessionConcepts/NSURLSessionConcepts.html

提交回复
热议问题