iPhone OS 4.0 adds multitasking APIs, so developers can write applications that multitask in a way that Apple says will not affect battery life or reduce performance. Apple CEO Steve Jobs claims that Apple took so long to bring multitasking to the iPhone operating system because it needed to figure out how to do so without compromising battery life or reducing performance of the foreground app -- and now it's figured out the secret sauce. (We'll see, of course, when it actually ships.)
The multitasking capabilities mean that apps can do background processing -- such as downloading a video -- when another program is running in the foreground. Apps that don't need to continue to execute essentially go into suspended animation; when you switch back to them, they pick up where you left off -- such as when returning to a game after checking email. Of course, app developers have to implement these capabilities, so developers will need to update their existing apps. You don't get the multitasking for free.
Apple's senior vice president of iPhone software, Scott Forstall, says that Apple examined tens of thousands of popular apps to understand how they operated, then figured out what APIs were needed to develop to support in-app and cross-app multitasking. Those APIs are:
- Background audio, so apps like Pandora will play music while you switch to another program, much as Apple's iPhone music player already does.
- VoIP, so Skype, Twitter, and the like can run in the background and alert you to incoming calls and messages. You can then take those calls and, say, search for a restaurant or check your flight status, even while the apps are going.
- GPS location services, so Global Positioning Satellite-based location continues to work when you switch to other apps. For example, you can get directions while listening to music.
- Location detection over cell towers, so the iPhone knows you switched cell towers, all without the use of GPS, which eats up battery power. This should also be a boon for the GPS-less iPod Touches.
- Server-less notifications (Apple calls this "local notification"), so alarm clocks and other apps can track status internally, even when running in background, and send notifications to you without being connected to a server, as was required in previous iPhone OS versions.
- Task completion, which lets apps continue to process in background until a task, like video download, is completed, rather than go into suspended animation.
- Fast app switching, which is the suspended-animation capability that uses no CPU resources and doesn't require the app to save its state before moving into the background.