0

I'm working on an enterprise iPad app which is a catalog of products used by sales agents. Due to the hight amount of contents on startup the app downloads all the products and related information, which amount to more than 20000 files/5GB of data.

This process generally takes about 1 hour and during this time the app is forced to stay in foreground.

Would it be possible to use the latest iOS7/8 background mode functionalities in order to allow the customer to work with their iPads meanwhile the app downloads all the data?

Thanks, DAN

DAN
  • 919
  • 1
  • 6
  • 23
  • How do you know it's going to take 1 hour? You can find general rules for background mode here http://stackoverflow.com/questions/9738488/run-app-for-more-than-10-minutes-in-background – Mercurial Jan 30 '15 at 17:36
  • It usually takes 1 hour to download all the content with the Wifi connection we have in the office. I'll have a look at the mentioned link, thank you – DAN Jan 30 '15 at 17:45
  • 1
    Sure, you can download the data using a `NSURLSession` background session (though background sessions generally are slower than foreground sessions). – Rob Jan 30 '15 at 17:56
  • Hi Rob, NSURLSession should be the solution, thanks! Here's a good tutorial: http://code.tutsplus.com/tutorials/working-with-nsurlsession-part-4--mobile-22545 and here an Apple's sample project: https://developer.apple.com/library/ios/samplecode/SimpleBackgroundTransfer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013416 – DAN Jan 31 '15 at 13:38
  • @Rob in order to download 20000 files should I manually enqueue 20000 NSURLSession background sessions and fire them sequentially or does something like NSOperationQueue come in help in such a situation? – DAN Jan 31 '15 at 13:50
  • 1
    With background sessions, you just instantiate single background session and then create all the download tasks with `downloadTaskWithURL/Request`, calling `resume` for each. Definitely no operation queue when dealing with background sessions. See [Background Transfer Considerations](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html#//apple_ref/doc/uid/TP40013509-SW44), for a few additional details, though. – Rob Jan 31 '15 at 14:00

0 Answers0