views:

93

answers:

3

Hello wise people,

I'm currently working on an app for iPhone, Blackberry and Android, but for now, I'm just inquiring about iPhone. (FYI, I'm an ideas guy; not an actual programmer, so please don't use too many syllables)

I desperately need the ability to incorporate the physical button from the iPhone headphones, into my app. So that, while my app is running, if the user clicks and holds the button for a designated amount of time, it triggers a specific function in my app. (as opposed to the functions it currently triggers in the apple API)

As you're aware, the button currently triggers functions within the standard iPhone API. Is it possible, within a third party app, for the app to utilize that button for its own purposes?

(If not, I must say that's incredibly infuriating and slightly fascistic, for a perfectly usable and highly useful external button to be in all the user's pockets, yet developers have no access to it)

Or, if it is impossible to use the headphones-button to launch a function in a 3rd party app, is it at least possible to purchase some sort of third party (or apple) physical button which can be incorporated into an app?

Hopefully I've been clear. My second question is, as a developer, is there a physical button product on the market which somehow connects to the iPhone, (perhaps via bluetooth) which the user can clip to their belt, and while my app is running, this button triggers a function within my app. when pressed.

If any of you kind people can help me with this urgent question, you will literally save my app.

Thanks so much in advance!!!!!

man'Otunes

A: 

You can get callbacks for your volume buttons in your own application but your app will probably be rejected if you intend to use these buttons for anything non-volume related.

MihaiD
+1  A: 

Yes -- if you forget about the AppStore.

There is no "documented" way to handle the menu/lockvolume/headset buttons in your app, (although undocumented receivers like -[UIApplication menuButtonDown:] do exist.)

However, if the app accompanies some external hardwares connected via the dock, you can use ExternalAccessory.framework to interact with that hardware.

KennyTM
You can use AudioSessionAddPropertyListener and AudioSessionGetProperty to monitor the volume buttons. These are documented. I think you would need to explicitly set up an audio session before registering for callbacks.
MihaiD
A: 

As above answers have stated, the possibility is slim for incorporating headset buttons in your app.

A safe way would be to use an external button via the dock connector or bluetooth. I don't know whether such ready-made bluetooth or dock "buttons" exist, but if you can find one, it wouldn't be hard to link them with your app.

In my opinion, a bluetooth connected button would be more easy to find (and more usable) than a dock connected one.

Good luck!

ravinsp
I agree, a bluetooth connected button would be the best. Most convenient for the user. I just wonder where I would find such a thing. I would guess, if it does exist, it would probably be pretty inexpensive. Just a button which turns a function on. Thanks for the hopeful post! I bet it does exist.
man'Otunes