如果应用程序被从任务管理器中杀死,NSUrlSession是否会继续文件传输? [英] Does NSUrlSession continue file transfer if the app is killed from task manager?

查看:182
本文介绍了如果应用程序被从任务管理器中杀死,NSUrlSession是否会继续文件传输?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过网上的各种样本(最后一个是这一个)为了更好地理解 NSUrlSession

I have tried various samples from the web (the last one being this one) in order to get a better understanding of NSUrlSession.

我希望看到的内容:文件下载即使触发它们的应用程序被杀死(例如由用户通过任务管理器),它仍将继续。但是这似乎没有发生。

What I was hoping to see: file downloads will continue even if the app that triggered them gets killed (for instance by the user through the task manager). However this does not seem to happen.

这是一个配置问题,或者如果应用程序被终止,后台文件传输不起作用?
我认为整个想法是iOS将重启应用程序。

Is this a configuration issue or does background file transfer not work if the app gets terminated? I thought the whole idea was that iOS will restart the app.

推荐答案

如果系统杀死你的应用程序和你的后台会话有活动下载,您的下载将继续,系统将在下载完成后启动您的应用。但是,如果用户强制退出您的应用,则会取消所有任务。

If the system kills your app and your background session has active downloads, your downloads will continue and the system will launch your app when the downloads complete. However, if a user force quits your app, all tasks get cancelled.

backgroundSessionConfigurationWithIdentifier的文档:


如果iOS应用程序被系统终止并重新启动,应用程序可以
使用相同的标识符来创建新的配置对象和
会话并检索传输的状态正在进行中,终止时间为
。此行为仅适用于系统正常的
终止应用程序。 如果用户从多任务处理屏幕终止app
,系统将取消所有会话的
后台传输。
此外,系统不会自动
重新启动应用程序这是用户强制退出的。用户必须
明确重新启动应用程序才能再次开始传输。

If an iOS app is terminated by the system and relaunched, the app can use the same identifier to create a new configuration object and session and retrieve the status of transfers that were in progress at the time of termination. This behavior applies only for normal termination of the app by the system. If the user terminates the app from the multitasking screen, the system cancels all of the session’s background transfers. In addition, the system does not automatically relaunch apps that were force quit by the user. The user must explicitly relaunch the app before transfers can begin again.

这篇关于如果应用程序被从任务管理器中杀死,NSUrlSession是否会继续文件传输?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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