PLEASE NOTE: This technique described here was originally done for iOS 2.0. It no longer works under iOS 4. If you want to turn on Bluetooth programmatically, you can do so using the iPhone GameKit SDK. However, this does not allow you to turn Bluetooth off. It only provides a method to turn it on.
I have long since abandoned using private APIs for any of my projects, so I unfortunately can not provide any advice on how you might be able to toggle Bluetooth under iOS 4.
Here's the most simple, yet useful application I've made for the iPhone. You click on the Bluetooth® icon and Bluetooth is toggled on or off. That's it. The app even immediately exits after you click on it.
This is much simpler than how you normally have to turn Bluetooth on or off via the iPhone settings. Compare. Here's a screen shot of my app. One tap and Bluetooth turns on or off.
Now here are the four screen shots of turning Bluetooth on or off via the iPhone settings menu.
Now, counting the final click of the home button, that's 5 clicks vs. just one with my app. Granted, it's a very simple app and many other people have suggested doing this same thing. However, what is frustrating is there's no way anyone can legally give this app to anyone. The Apple iPhone SDK specifically prohibits using private framework APIs, and unfortunately, to access the Bluetooth functionality requires using the private frameworks.
Hopefully some day soon Apple will change this policy. There's a lot more useful things that can be done in these apps if Apple would just allow developers to use the private frameworks. I currently have an outstanding query into Apple's developer support regarding this issue (I get two free tech support queries with my developer license) but it's been almost a month now and Apple still hasn't responded.
Interestingly, as of today, there are actually several applications in the iTunes App Store which do make use of the private frameworks - in direct violation of the SDK license agreement. It appears the people in charge of approving apps either have no way to automatically scan an app for private framework API calls or they are turning a blind eye on it since Apple gets 30% cut of all money these applications earn.
As for me, I'm currently not willing to risk my iPhone developer license by knowingly submitting an app that is in violation of this policy.
The Bluetooth® word mark and logos are registered
trademarks owned by Bluetooth SIG, Inc. and any use of
such marks by Stormy Productions is under license. Other
trademarks and trade names are those of their respective
Friday, August 29, 2008
The most useful iPhone app I can't release
Posted by Mostly Torn at 10:11 AM
All content copyright © 2009 Brian Stormont, unless otherwise noted. All rights reserved.