The Tapbots Multitasking Workaround
Tapbots, if you haven’t heard of them (which I found doubtful), are an iOS application development company run by designer Mark Jardine and programmer Paul Haddad. I’ve had the pleasure of beta testing a few of their applications, and I own and love everything they’ve created to date.
That said, my favorite application of theirs thus far is Pastebot, which allows you to sync clipboards between your Mac, iPhone, and iPad. The only feature missing from Pastebot was the ability to do this syncing without the app actually running on your phone, which, sadly, was impossible with Apple’s current implementation of multitasking on iOS 4. Or so we thought.
Consider this excerpt from the iOS Application Programming Guide’s section on background code execution:
Applications that play audio can continue playing that audio while in the background. To indicate that your application plays background audio, include the
UIBackgroundModeskey to itsInfo.plistfile. The value for this key is an array containing theaudiostring. When this key is present, the system’s audio frameworks automatically prevent your application from being suspended when it moves to the background. Your application continues to run in the background as long as it is playing audio. However, if this key is not present when the application moves to the background, or if your application stops playing audio while in the background, your application is suspended.
This is how Pandora’s iPhone app streams audio while in the background. When your app plays audio in the background, it does not transition into the background suspended state. That means whatever code is running keeps running. This is, unless you’re a VoIP application, the only way your app can keep a persistent connection or otherwise run code indefinitely in the background. This will be taken advantage of in an upcoming Pastebot update to allow syncing to take place without the app running in the foreground.
Some caveats, however:
- Tapbots’ original idea was to loop a silent audio file to keep background audio alive while running the syncing code. Apple rejected them for abusing the background audio API, however. Therefore, the app must produce audible sound to be accepted into the App Store.
- Because the app doesn’t get suspended when playing background music, a lot of care has to be taken to make sure that your app isn’t doing a lot of work in the background. Otherwise, the system may kill you, or Apple will likely reject you from the App Store for bad user experience.
- This will probably interfere with the user’s ability to watch videos or play music from the iPod app. We’ll have to see how it works once Pastebot and other apps start implementing this idea.
- Pastebot’s latest update hasn’t been approved yet, so there is a slight possibility that Apple will still reject them for abusing the background audio service, though Tapbots seem optimistic.
In terms of how to present this option to the user, you’ll most likely end up giving the user the option to play their own music from the iTunes library. This means you’ll have to inform the user that to keep your app’s service running indefinitely in the background, the user has to keep the audio playing. This will undoubtedly come off sounding weird to your user, who has just been told that if he wants to keep <whatever, probably audio-unrelated thing your app does> while your app is (seemingly) not running, he/she needs to keep listening to his/her music. I’m not entirely sure what the most HIGular (I don’t care if that’s not a word) way to do this is, but Tapbots will definitely find a good solution being the UX geniuses they are, and set an example for other developers.
For more information from Tapbots themselves, see: http://tapbots.com/blog/pastebot/pastebot-music-in-background




