Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will download resume after closing my app in Background Mode

Tags:

ios

swift

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.

Is it possible to resume downloading task after force closing my application by user? How?

like image 473
Saranjith Avatar asked Dec 29 '16 12:12

Saranjith


People also ask

How do you see if anything is downloading in the background on iPhone?

All replies. Check in Settings>iTunes & App Store>Automatic Downloads>Updates>On. If that is set to "On", any apps that require updates are being downloaded in the background.

Can Safari download in the background?

Anything can be downloaded and saved to the disk for later use, making your iOS device act more like a computer. On top of that, Safari supports background downloading so you can multitask like a boss while those files are being retrieved from the web.


1 Answers

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!

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)

Refer the apple documentation, It states,

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.

like image 130
Ketan Parmar Avatar answered Nov 10 '22 13:11

Ketan Parmar