The right way to do iPhone 4.0 OS Backgrounding . . .
mobypicture.com
mobypicture.com
The right way to do backgrounding:
- Consume the least amount of CPU possible. Optimize, optimize, optimize! If you're implementing a network app and there are no events coming in over the network, your process should be doing nothing, blocked in the kernel.
- Drop as much RAM as possible before you go under. There's only so much RAM on the device. Apple's frameworks try to drop as much as they can, but if you're holding onto a cache or anything that can reasonably be reconstructed, now is the time to drop it. This increases the likelihood of you surviving in the background after your process has been put to sleep, too.
- Work seamlessly. If iOS terminates your app due to low resources, re-start exactly where you were before. Don't show an annoying dialog like this one when you switch to the background. Don't show a ridiculous "splash" screen that wastes user's time. Just work.
If done right, you can maintain a very small footprint, and then you don't need to annoy the user by asking every time: "is this OK?".
Most apps do nothing in the background. Others, like music or GPS apps, it should be obvious to the user that these apps are doing stuff in the background. For an app like Trapster, however, it would be easy for the user to forget or not understand that it's working in the background. I, as a user, might appreciate this kind of warning from an app that I normally would not want running in the background.
By default, I would have it not do anything in the background (which is how it obviously works on OS 3). I would have a setting that enables it to run in the background, as well as a setting that enables the warning. It sounds like that's exactly what they're doing, although I don't know what their default behavior is.
Now that you've told me, if I don't want to consume the battery, what do I click?
Or, consuming the battery is fine, and I want to keep Trapster running. What do I click?
// Seems this is a better example of the wrong way to do backgrounding.
I'd be okay with it as long as it only popped this up the first time it went to background mode. Arguably it'd even be a good feature since a lot of users might not know about the tradeoff involved in backgrounding.
If you're concerned that most of your users won't want this, then turn it off by default and have an option to turn it on.
The model to follow here is the iTunes Remote app. It allows you to remain connected in the background, but you have to activate it from settings, where there's a little explanation of the trade-off.
Doing it the way this app does is plain nasty.
Some mobile OSes have an application architecture and structure that were built to be multitasked, others are only now adding it and it shows in some apps, like this. It's all about the mindset that the platform takes to multitasking. That is, if you want to call the various implementations "multitasking".