I want to intercept the proximity sensor without turning off the display.
I know by the documentation that I have two Bool variables:
proximityMonitoring
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 setProximityMonitoringEnabled:YES];
if (device.proximityMonitoringEnabled == YES) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(proximityChanged:)
name:@"UIDeviceProximityStateDidChangeNotification"
object:device];
}
- (void) proximityChanged:(NSNotification *)notification {
UIDevice *device = [notification object];
NSLog(@"In proximity: %i", device.proximityState);
}
Source: http://www.whatsoniphone.com/blog/new-in-iphone-30-tutorial-series-part-4-proximity-detection/
Will help to detect current state of sensor.
Public API that allows screen dim:
[UIScreen mainScreen].wantsSoftwareDimming = YES;
[UIScreen mainScreen].brightness = $your_brightness_value;
Found here: Change to wantsSoftwareDimming in iOS 6?