关闭应用程序后,后台传输下载任务失败 [英] Background transfer download task failed when app was closed

查看:101
本文介绍了关闭应用程序后,后台传输下载任务失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了后台nsurlsession来执行下载任务.该应用程序在后台运行时效果很好.但是,当我关闭应用程序时(双击主页"按钮并向上滑动),下载任务似乎被取消并失败了,这使我在重新启动应用程序时从头开始重新下载.根据Apple文件,即使该应用程序不再运行,后台传输也能正常工作.我做错什么了吗?

I have created background nsurlsession to perform download task. It worked well when the app was in background. However, download task seems to be canceled and failed when I closed the app (double click "Home" button and swipe up), and it made me to download from the beginning again when I relaunched the app. According to Apple document, background transfer works even the app is no longer running. Am I doing anything wrong?

推荐答案

来自

如果iOS应用被系统终止并重新启动,则该应用可以使用相同的标识符来创建新的配置对象和会话,并检索终止时正在进行的传输状态.此行为仅适用于系统正常终止应用程序的情况. 如果用户从多任务屏幕上终止应用程序,则系统会取消所有会话的后台传输.

因此,如果iOS本身在正常情况下关闭您的应用程序,后台传输将继续进行,但如果您从多任务屏幕上退出 force 退出,则它将终止所有传输.

So, while background transfers will continue if iOS itself closes your app during the normal course of things, if you force the quit from the multitasking screen, it will kill all your transfers.

这篇关于关闭应用程序后,后台传输下载任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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