我有一种情况,当设备收到推送通知时,我会发送一个 NSURLSession
和一个 NSURLConnection
。我有几个关于 NSURLSession
的问题。
如果互联网连接丢失,NSURLSession 的
数据任务是否会在后台自动恢复?
如果最初没有互联网,NSURLSession
会自动尝试完成任务,还是 session 只是返回错误?
最佳答案
看来要由您来处理重试了。
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).
关于ios - NSURLSession 什么时候运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19236440/