ios – NSURLSession何时运行?

ios – NSURLSession何时运行?,第1张

概述我有一种情况,当设备收到推送通知时,我会发送NSURLSession和NSURLConnection.我有几个关于NSURLSession的问题. 如果互联网连接丢失,NSURLSession的数据任务是否会在后台自动恢复? 如果最初没有互联网,NSURLSession是否会自动尝试完成任务,或者会话是否因错误而返回? 看起来你需要处理重试. When any task completes, th 我有一种情况,当设备收到推送通知时,我会发送NSURLSession和NSURLConnection.我有几个关于NSURLSession的问题.

如果互联网连接丢失,NSURLSession的数据任务是否会在后台自动恢复?

如果最初没有互联网,NSURLSession是否会自动尝试完成任务,或者会话是否因错误而返回?

解决方法 看起来你需要处理重试.

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

总结

以上是内存溢出为你收集整理的ios – NSURLSession何时运行?全部内容,希望文章能够帮你解决ios – NSURLSession何时运行?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1114458.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存