// Enabled monitoring of the sensor [[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; // Set up an observer for proximity changes [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sensorStateMonitor:) name:@"UIDeviceProximityStateDidChangeNotification"
object:nil];
- (void)sensorStateMonitor:(NSNotificationCenter *)notification { if ([[UIDevice currentDevice] proximityState] == YES) NSLog(@"Device is close to user."); else NSLog(@"Device is not closer to user."); }
No comments:
Post a Comment