Download in background in iPhone - iphone

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

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?

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.

Related

Will my app work with a new iOS?

I have made an app for iOS 5.1..
Will the app work with iOS 6 also? Or do I have do to any updates in the code or something?
Thanks!
Apple has good backward and forward compatibility so it should work with no problem
There are cases when you use some specific libraries that your app will need a resubmission
but 99% of the cases your app will just work good
One point to note here: is if apple will change the resolution of their next devices you may find some icons that are low quality (happend when iphone 4 was first release)
But regardless of that your app should work.
Usually the OS versions are backward compatible for the apps.

iOS5 - Downloading 100MB in background when app is not running

iOS5 has multi tasking enabled feature.
So, When the app is in background mode, can I download the data in background?
Will apple permit to write such code?
If yes, any examples will be of great help.
You can. You could use one of methods described in iPhone - Backgrounding to poll for events to get 'constat background' for you
But Apple is very unlikely to approve such abuse for AppStore

daemon process in iphone SDK 4.1?

is there any API to enable background process...(in IPHONE SDK 4.1)?
Not in the conventional sense, no. Apple allow a restricted number of use cases, such as VoIP and music, but other background processes are not allowed. This is well documented on the iOS Developer Centre.

Does supporting multitasking in iOS 4 mean dropping support for iOS 3?

I can't find anywhere definitively, if you build an app against the iOS 4 SDK, to thus support multitasking, does that mean the app won't work in iOS 3? If not, how can you support iOS features like multitasking but still support iOS 3? I'm sorry if there are Apple docs on this, I'm happy to read them, I just can't find them. Thank you
You can build against a 4.x Base SDK, and set the Deployment Target to 3.x.
But you have to make sure not use any of the new 4.x APIs without checking for their availability first (or you will start to run, then crash as soon as you call one of those APIs on a device running 3.x). And you will need to test thoroughly on an actual device running iPhone OS 3.x since there is no simulator support for this kind of OS portability testing.
In some cases, converting a 3.x app to also allow what is called "multitasking" under 4.x is as easy as rebuilding the app using a new 4.x Base SDK, but leaving the deployment target where it was at 3.x, and adding an applicationWillResignActive: delegate to handle both suspend and potential termination.
No it does not. iOS 3 just ignores the delegate methods that get called.
However, if you try and launch a background task, you'll have to check for the API first, otherwise yeah, you'll not run on 3.

iPhone app alert without push notification?

How can I alert a user that they need to do something without using a push notification? For instance, if I have an alarm clock app, how can I get it to ring when it is not already running without using a push notification?
You can't. As of writing, iPhone OS does not support background processes. (There wouldn't be any need for push notifications if iPhone OS supported background processes!) You can alert the user while your application is running using UIAlertView, but once your app is closed, you can't do anything.
As #Henrik P. Hessel mentions, it is rumoured that background processes will finally be supported in iPhone OS 4.0. Rumours also suggest that iPhone OS 4.0 will be previewed at the January 27 Apple Special Event. We'll soon see whether they're true...
That's not possible yet. There're rumors though that multitasking and background processes will be allowed in iPhone OS 4.0. But that's more than speculative.
You can't do it in the official iPhone OS 3.1.2 or lower. As mentioned by others, there are rumors that iPhone OS 4.0 will support background processes, but nothing about that has been confirmed by Apple.
You may, however, develop an application that can alert the user without push notifications if you forgo the officially sanctioned SDK + App Store route, and build applications for jailbreak (Cydia or Rock). There are a growing number of for-pay apps in jailbreak land these days. Of course, this will limit your app's exposure, and will be negatively looked at by Apple, but if you have a niche market (and don't mind requiring jailbreak users) or this is only for yourself/friends, this might be a good direction to go in.