John Gruber has written about how Google’s Mobile App is using “private iPhone APIs” to access proximity sensor information. While using Google’s app, you can place the phone to your ear to initiate an audio search. It’s a nifty feature, but:
[T]he only thing apps can do with the proximity sensor is turn it on and off. [..] An app can check the status of this property (is it on or off?), and can toggle it, but that’s it. After an app has turned the proximity sensor on, the app never finds out when or if it has actually been engaged. There is no way for an app to be notified when the proximity sensor has been triggered. No way, that is, via the public APIs.
Gruber goes on to hint that after a little “work” he’s found a method called proximityStateChanged that can be used to detect when the proximity sensor is tripped. As an undocumented method, he concludes that Google might be getting favorable treatment in being able to use private APIs “just because they’re Google.”
Ross Boucher, founder of 280 North, came back with an interesting blog post called Google, iPhone, and Thinking Like a Programmer where he came up with an alternative technique to detect proximity to the iPhone – with code (and even a full app) included. Despite his clever workaround, Boucher thinks that if Google and some other vendors have been given special dispensation to use special iPhone features, it’s a reasonable tradeoff.