gpt4 book ai didi

ios - 如果应用程序从任务管理器中被终止,NSUrlSession 是否继续文件传输?

转载 作者:可可西里 更新时间:2023-11-01 03:08:58 26 4
gpt4 key购买 nike

为了更好地理解 NSUrlSession,我尝试了网络上的各种示例(最后一个是 this one)。

我希望看到的是:即使触发下载的应用程序被终止(例如,用户通过任务管理器终止),文件下载仍将继续。然而,这似乎并没有发生。

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

最佳答案

如果系统终止您的应用程序并且您的后台 session 有事件下载,您的下载将继续并且系统将在下载完成时启动您的应用程序。但是,如果用户强制退出您的应用,所有任务都会被取消。

Documentation for backgroundSessionConfigurationWithIdentifier:

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.

关于ios - 如果应用程序从任务管理器中被终止,NSUrlSession 是否继续文件传输?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25047427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com