3

As per the latest update of Kindle V2.5, it has support of "continue downloading books while the app is in the background on iOS 4 devices".

How is it possible to download content in background? As per the iOS multitasking documentation, only audio, voip & location updates are possible in background. And I've also maken sure that NSURLConnection doesn't download new data work while app goes background. Then how's it possible with Kindle app?

Edit: I haven't checked Kindle App in iOS4 multitasking enabled device. So if anyone let me (& community) know what exactly Kindle app does to download, that would be very much helpful.

Sagar
  • 3,159
  • 3
  • 29
  • 28

2 Answers2

7

Yes you can. Go back to the document you mentioned, and check the code at the Completing a Finite Length Task in the Background section. In this way you can run generic tasks in the background, including accessing the network and uploading files.

Edited: I answered a similar question on SO before, check this, iphone - Connecting to server in background

Community
  • 1
  • 1
Di Wu
  • 6,436
  • 3
  • 35
  • 51
  • OK. As the method name suggests, the task should be a finite length. However, downloading an ebook (like what Kindle app does), cannot be finite length. Because it depends on the network availability & strength. So in that case, how to define the length of the task. And what if iOS removes the app from memory in between!! – Sagar Jan 17 '11 at 04:46
  • @Sagar: Actually in your code the **beginBackgroundTaskWithExpirationHandler:** method should be paired with a method called **endBackgroundTask:**. It is your responsibility to end a background task when you think this task is finished or this task is not likely to be finished and therefore needs to be terminated. As for your second question, if your background task hasn't finished when iOS think the time is up (~10 minutes at maximum), it'll kill your app rather than just freeze it in the memory. – Di Wu Jan 17 '11 at 05:21
  • 1
    btw please don't use things like **!!** in your question. We are here to help you as volunteers, not as your employees. **!!** won't make your questions any attractive. – Di Wu Jan 17 '11 at 05:25
  • 1
    Thanks for your feedback. I apologize for the bad grammar. – Sagar Jan 17 '11 at 06:46
5

Completing a Finite Length Task in the Background

You can use these methods to do pretty much anything you want, but you've got to finish it all up in <10 minutes. I use it to continue uploading an image after the app has closed.

kubi
  • 48,104
  • 19
  • 94
  • 118