IPhone multitasking and background updating
marco.org
marco.org
The advantage is that making things simpler allows them to concentrate and spend more time making them better, while the disadvantage is that it leaves lot of developers unable to meet their users' needs.
The alternative approach (Android) where APIs are pretty general allows far more developer power, then downside there being that it makes a lot of things harder/more time-consuming.
I also like his idea of iOS only allowing polling when signal is above a threshold. Data requests while in marginal coverage chew battery at an extraordinary rate. Changing my Fetch frequency on 3 mail accounts from 15 mins to 60 mins more than doubled battery life.
ReMail approached this by setting a timer to remind the user to launch the app and download mail to index. The data load for checking mail with arbitrary attachment sizes is considerably more than what Marco's talking about. I'd bet the data transfer problem is something Apple considered.
Even for small data sets, using data continually adds up. After getting their first data bill, users might prefer to be manually in charge of their data usage.
I'm trying to illustrate how there is no perfect ideal approach.
Most of Apple's APIs are wonderfully general (e.g., look at their full 3d-aware Core Animation capabilities that are better than any desktop system (other than Mac OS X, which shares the same capabilities).
They specialize APIs when it would be harmful to generalize.
They're fighting at every turn for battery life (I'm at WWDC this week, and have seen that mantra (optimize for battery life) at nearly every talk), which is tough on developers but great for end users.
I suppose apps that are sent into the background are just frozen in their current state and continue to run where they left of, when going into foreground? Just a guess, though..
Edit: Downvoted? Am I wrong? Just curious
I had the hope of little more technical detail, though
As long as these idevices only have 256MB of RAM this will be a problem. I think the approach Apple is taking is the right approach. An app like Pandora should be able to spin off a "stub" process that doesn't have any of the UI overhead but simply the network and audio code to continue playing an existing stream.
These are all "hacks" that will hopefully be outdated in a couple years when we're hacking away on our A9 cortex 2 ghz. dual core iPads with 4GB of RAM.... (hey, I can dream right?)
Developer documentation is, of course, better. But I think it's all under NDA.
Until now, when the user pressed the home button you were able to write your state to flash if necessary. Now there is another way to 'freeze' your app and keep the state in memory -- at least until iOS4 decides your app won't be needed soon and fully quits it to free memory.
If you use the APIs mentioned above it is possible to continue playing (streaming) music, doing something else during a Skype call or update your location whenever you connect to a new cell tower* . If you need turn-by-turn you get access to constantly ask for GPS, this aside from calling/playing music is the only 'real' multitasking as it continues in the background until you tell it to quit.
The Worker API allows you to complete a task, for example continue uploading that video file to Dropbox. Once it's done the Dropbox app quits (or is frozen in memory as everything else).
Push notifications allow to access a server but it seems as someone else here mentioned the payload is too low, and only accessible as soon as the app is activated.
I can't tell for sure though as I'm not an iPhone developer just following it closely and most of this information comes from the January(?) keynote when iOS4 was introduced.
*Because GPS sucks battery you app gets called whenever you connect to a new cell tower, this according to Apple, should be sufficient for services like Google Latitude where the exact position at any given point isn't that important like it is for turn by turn navigation.
So, what is missing (i guess) is some background service API. Sounds pretty much like the Android way (minus the background service). But it should be good enough for the majority of apps, i think.
I'm sure Apple would do it properly and have all apps with scheduled tasks accessible from the Preferences screen so you could disable or change the schedule of them easily.
They could even allow the users to set the checking interval – there is already a setting for (non-push) Mail, they wouldn’t even have add another one, just turn that setting into a “Load new stuff every X minutes” setting. (I’m certain that waking the device every thirty minutes, turning on the radios and then checking everything at once probably saves the most energy.)
That these background services are not composable puts some limits on their potential usefulness, but it sounds like this plus the existing services would cover most bases.
Or am I wrong?