ios – 在后台模式下关闭我的应用后会下载简历

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

在用户强制关闭我的申请后,我可以完成下载任务吗?怎么样?

解决方法

不,当您的应用被用户终止时,您无法继续下载!您的应用必须要求保持背景状态!因为如果用户强制关闭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.

更新:(如评论中所述)

Refer the apple documentation,它说,

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.

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.

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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...