iOS:强制退出应用是否会禁用使用NSURLSession的背景上传? [英] iOS: Does force quitting the app disables background upload using NSURLSession?

查看:152
本文介绍了iOS:强制退出应用是否会禁用使用NSURLSession的背景上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题在于 NSURLSession NSURLSessionUploadTask

我正在将大文件上传到服务器,并注意到当我强制退出应用程序时,整个后台上传操作都停止。但是,当应用程序通过Xcode /调试器运行时上传开始,则当我通过Xcode的停止按钮停止应用程序时,我的上传完成甚至。我怀疑强制退出应用程序使用Xcode模拟一个iOS系统命令,而不是用户操作。

I'm uploading large files to server and noticed that when I force quit the app the whole background upload just stops. However, when upload starts while app is running through the Xcode/debugger, then my upload completes just fine even when I stop the app running via Xcode 'stop' button. I suspect that force quitting the app using Xcode simulates an iOS system command and not a user action.

所以我的问题是,是否是真的iOS会立即取消 NSURLSessionUploadTask 当用户强制退出应用程序?由于某种原因,我至少希望应用程序的错误回调,但没有任何反应。

So my question is whether it's true that iOS would immediately cancel NSURLSessionUploadTask when user force quit the app?? For some reason I would at least expect an error callback to the app, however nothing happens.

推荐答案

测试的背景任务将运行确定如果应用程序只是放到背景。但是,如果用户强制手动退出应用程序,则iOS将取消所有计划的后台任务。因此,下次启动应用程序时,我会收到所有回调函数的代码,并显示已取消的任务的错误代码。

I can confirm now after a bunch of testing that background task will run ok if the app is just put into background. However, if user force quit the app manually, then iOS cancels all scheduled background tasks. So next time the app is launched I'm getting all the callbacks to the delegate with the error code of a canceled task.

希望它帮助某人查找同一个东西。

Hope it helps someone looking into the same thing.

这篇关于iOS:强制退出应用是否会禁用使用NSURLSession的背景上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆