Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does iOS 4 make “Real Multitasking” available to 3rd party developers?

Tags:

ios

iphone

ios4

Ever since the first beta came out I’ve been trying to find out if “real” multitasking is possible — i.e. can you put a program in the background and have it hang on to a network connection indefinitely?

I’m thinking about IM or IRC apps, for example. I’ve compiled an app myself on iOS 4, and without changing a thing it appeared to stay running in the background, but for all I know it was just suspended to memory.

The docs say the best you can do is request up to 10 minutes, but in the developer presentation they showed off Skype sitting in the background and then notifying the user that a call was coming in. Does anyone know for sure how this all works?

like image 323
Phil Kulak Avatar asked Jun 09 '10 05:06

Phil Kulak


4 Answers

It appears the answer is no. The API for Skype is a very special case, called the "voip" mode, and requires special behavior, such as marking the socket in use for VoIP.

You can receive alarm notifications in the background (such as time passed). The amount of time you are in the background running state is severely limited by the OS.

Android's background model is complete and in many ways much nicer.

Apple has a guide named "Supporting Multitasking In Your Applications" which you should be able to locate.

like image 136
Yann Ramin Avatar answered Nov 11 '22 12:11

Yann Ramin


Apple's iOS 4 developer docs outline this all very clearly.

When your app is closed or switched away from, it is almost immediately "suspended", meaning the OS freezes the app's state. When the user switches back to your app, your code keeps running just where it kept off. You don't need to add any code to your app to do this, just compile it against OS 4.

The above is true in most cases. There are two reasons the "suspended" model may not apply:

1) If the device starts to run low on memory, the OS will start terminating suspended apps that haven't been switched to in a while, without warning. This is why it's in your best interest for your app to remember it's state as well, so if your app is terminated, then re-opened, the user doesn't really notice because it still returns to right where they left off.

2) Your app uses one of the "background" APIs. These are for audio playback, VoIP services, or location services. In this case, your app is allowed to continue running in the background but only has access to those APIs. Additionally, your app can designate certain long-running tasks as "background tasks" that need to be completed before the app is suspended or terminated, like uploading pictures to Flickr or rendering a video, etc.

The "background task" method doesn't cover pinging servers indefinitely, as there is a time limit for the task, after which it will be forcibly halted. Apps that need that sort of functionality are expected to implement push notifications, just as before.

That should clear this up. All in all I think it's a pretty elegant solution to multitasking on a mobile device.

like image 38
Alex Ford Avatar answered Nov 11 '22 14:11

Alex Ford


iOS 4 applications can either be running or suspended. The operating system will try to keep as many requested applications as possible in memory, while all other applications are suspended.

Applications that run in the background can access features such as navigation, audio, and VOIP (but NOT instant messaging). So it looks like you might be out of luck.

-- PC World Multitasking on Apples iPhone 4

like image 1
Kevin Sylvestre Avatar answered Nov 11 '22 13:11

Kevin Sylvestre


It is possible for apps to request background time. Read the docs. I would say it iOS is "controlled multitasking".

like image 1
Moshe Avatar answered Nov 11 '22 12:11

Moshe