Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep running NSOperationQueue when app goes to background

I'm downloading files using NSOperation (s) and adding them NSOperationQueue. NSOperationQueue is getting suspended when app goes in the background. Is there any work around if queue will not suspend in the background and start the next operation?

like image 936
Afnan Avatar asked Dec 13 '12 09:12

Afnan


1 Answers

While your queue is running use the UIApplication beginBackgroundTaskWithExpirationHandler call to start a background task that will keep your downloads running.

I generally wrap up each operation with its own beginBackgroundTaskWithExpirationHandler call, and queue the next one up before I call endBackgroundTask that way the queue keeps running.

note an individual background task is limited to 10 minutes of operation, after that iOS will suspend the app.

like image 187
Tony Million Avatar answered Oct 01 '22 22:10

Tony Million