在后台模式下关闭我的应用程序后会下载恢复 [英] Will download resume after closing my app in Background Mode

查看:117
本文介绍了在后台模式下关闭我的应用程序后会下载恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现可以在后台应用程序模式下载。我在XCode中实现了后台提取模式,并注册了后台任务,并且工作正常。

I figured out about it is possible to download in background mode of application. I have implemented Background Fetching Mode in XCode and registered background task and its working fine.

用户强制关闭我的应用程序后是否可以恢复下载任务?如何?

推荐答案

不,当您的应用被用户终止时,您无法继续下载!您的应用必须要求保持背景状态!因为如果用户强制关闭app意味着,他不想再运行它了。如果您的应用程序被系统暂停,那么它可以被唤醒,但如果它被用户终止则不会被唤醒!

No, you can't continue download when your app get terminated by user! Your app must require to remains in background state!!! Because if user force close app that means, he doesn't want to run it anymore. If your app is suspended by system then it can be wake up but not if it's terminated by user!


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

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.

更新:(如评论中所述) )

Update : (As asked in comment)

请参阅苹果文档,它声明,


此方法可让您的应用知道它将被终止并完全从内存中清除。您应该使用此方法为应用程序执行任何最终清理任务,例如释放共享资源,保存用户数据以及使计时器无效。您执行此方法大约需要五秒钟来执行任何任务并返回。如果方法在时间到期之前没有返回,系统可能会完全终止该进程。

This method lets your app know that it is about to be terminated and purged from memory entirely. You should use this method to perform any final clean-up tasks for your app, such as freeing shared resources, saving user data, and invalidating timers. Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.

对于不支持后台执行或与iOS链接
的应用程序3.x或更早,当用户
退出应用程序时,始终会调用此方法。对于支持后台执行的应用程序,当用户退出应用程序时,通常不会调用此方法
,因为在这种情况下app
只是移动到后台。但是,在应用程序在后台运行
(未暂停)的情况下,此方法可能会调用
,系统需要因某种原因终止它。

For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.

在调用此方法后,该应用程序还会发布
UIApplicationWillTerminate通知,以便为感兴趣的对象提供
的机会来响应转换。

After calling this method, the app also posts a UIApplicationWillTerminate notification to give interested objects a chance to respond to the transition.

这篇关于在后台模式下关闭我的应用程序后会下载恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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