3

Is it possible to download a file while the app is in background in iPhone 4?

hpique
  • 119,096
  • 131
  • 338
  • 476

2 Answers2

6

Yes, it is.

It's supported in ASIHTTPRequest as of v1.8:

http://allseeing-i.com/ASIHTTPRequest/How-to-use#background_downloads_ios

(There was also an experimental branch of v1.7 with it at http://github.com/pokeb/asi-http-request/commits/backgroundtask but this appears not to exist anymore.)

It's also supported in AFNetworking, see Does AFNetworking have backgrounding support?

Community
  • 1
  • 1
JosephH
  • 37,173
  • 19
  • 130
  • 154
  • That URL gives "That page doesn't exist!", hopefully temporarily? – JOM Dec 16 '10 at 10:46
  • 1
    @JOM That functionality is part of the mainline as of v1.8 - I've updated my answer with a link to the documentation. – JosephH Dec 23 '10 at 21:09
  • Is there a better solution nowadays ? something with AFNetworking perhaps? ASIHTTPRequest is no longer available. – Shai Mishali Apr 09 '12 at 12:52
  • 1
    @ShaiMishali I've added an AFNetworking link to my answer. ASIHTTPRequest is still available and works just fine, though may not be a good choice for new projects. – JosephH Apr 09 '12 at 15:59
3

Under iOS 4.x, you can use request some background time using UIApplication beginBackgroundTaskWithExpirationHandler: and perhaps continue a file download for a limited period of time.

See Apple's document on "multitasking" background execution for details.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153