views:

125

answers:

2

The docs related to proximity sensing state that if the proximity sensing APIs are used on a device without a proximity sensor (i.e. iPod touch, iPad) they will just return as if the proximity sensor has fired.

Aside from checking the [[UIDevice currentDevice].model] string and parsing for "iPhone", "iPod touch", or "iPad" is there a slicker way to determine if a proximity sensor is on a given device?

+1  A: 

Apple’s documentation notes that “Not all iPhone OS devices have proximity sensors.” To determine if the device your app is running supports proximity monitoring, set the proximityMonitoringEnabled property to YES, then check its value:

UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
if (device.proximityMonitoringEnabled == YES)
    // do something

Source: http://www.mobileorchard.com/new-in-iphone-30-tutorial-series-part-4-proximity-detection/

David Gelhar
+1  A: 

Taken from UIDevice documentation:

proximityMonitoringEnabled

A Boolean value indicating whether proximity monitoring is enabled (YES) or not (NO).

...

Discussion

....

Not all iPhone OS devices have proximity sensors. To determine if proximity monitoring is available, attempt to enable it. If the value of the proximityState property remains NO, proximity monitoring is not available.

Claus

Claus Broch