07 October 2008

Technical: Running iPhone Apps in the Background: How to Find the Application Bundle Name

UPDATE: Newer versions of the backgrounder software come with a GUI interface that lets you do this stuff, so unless you are using an old version (can't think why you would) the below instructions are deprecated.

This post probably won't be terribly interesting to those of you looking for travel adventures, but I figured if I've got a blog, I might as well keep track of useful things I learn how to do and share them with the world. For now my plan will to start any such post this with the string "Technical: " so that the uninterested reader may safely skip over it.

I've recently started using a fantastic jailbroken application for the iPhone: Backgrounder. The beauty of this application is in it's simplicity. It lets you do a straightforward thing that for some reason Apple entirely prohibits, namely run applications in the background.

Why would you want to do this? Well the default behavior for any third-party application is that as soon as the home button is pressed and that app disappears from view the application stops running entirely. Now this is good in many circumstances, but there are times when it's a real pain or worse. For example let's say you are using the new Fring client on your phone. Wonderful you can make and receive calls using Skype (or another SIP provider). There's only one hitch: you can only receive incoming calls if you have the application open. This means you can't even check your email if you want to be certain not to miss a call! Here's another one. Let's say you use NetNewsWire to read your news and you quickly close the program to do something else. When you go back to NetNewsWire, you'll have to wait for the program to start up and then renavigate to the story you were reading - what a pain! Another app for which backgrounding is essential is Pandora (I'll let you piece the why together).

Backgrounding lets you avoid all of this pain. However the default behavior is that you need to manually enable backgrounding for the applications you desire each time you start that application after having rebooted.

There is a way around this, by specifying the applications that you want to automatically background, as explained on the Backgrounder documentation page. However, you need to know what the application bundle name is and no one seems to fully explain how to do this.

So how do you do it? Well if your application is from Cydia then all you need to do is look at the package Details and use the contents of the ID field as your application name. However if your application comes from the app store things are significantly harder.

First you need to find the directory in which your applications is stored:

find / -name *
youAppNameHere* -print
example: find / -name *Fring* -print

Yes Fring.app/ is a directory.

Once you've found the proper directory cd into it and look for the Info.plist file (theoretically if you've got the BSD subsystem running you should be able to see it using more, however in practice I had to first scp it over to my laptop and examine it there). It should look something like this:
ngland.FringZMainWindowUFringZ(SDK_NAME) RenXiphoneosS6.0_^P^SResourceRules.plistUfringT??

The string following
CFBundleName highlighted in green is the actual app name. For whatever reason there will be a series of characters that appear to specify the app version along with some garbage characters before the actual app bundle name, which terminates at ZMainWindowUFringZ. Often it's fairly straightforward to find the bundle name as the convention is that is starts with com. however not all developers obey this convention so sometimes you'll just have to make an educated guess.

Anyway once you've gotten the name you can put it in the preferences files at /var/mobile/Library/Preferences/jp.ashikase.backgrounder.plist . To test that backgrounding is in effect simply open the application and then hold down steadily on the iPhone's home button, if you get a message saying "Backgrounding Disabled" then you know you've done it right (on the other hand if it tells you "Backgrounding Enabled" you are either using the wrong name or have otherwise messed up the instructions for enabling automatic backgrounding of that application).

No comments:

Post a Comment