The Uidevice class provides APIs that enable you to track the characteristics of your device, including battery status and proximity sensors. Both of them provide updates in the form of notifications that they can subscribe to notify your application when there are important updates.
1) Start and disable proximity sensors
Proximity is an iphone-specific feature at this point. IPod Touch and ipad do not offer proximity sensors. There is little benefit from using proximity sensors unless there is some compelling reason to hold the iphone relative to the body part (or vice versa).
When the proximity sensor is enabled, it has a primary task. He will detect if there are larger objects in front of them. If it is, he will turn off the screen and send a regular notification. Moving the blocked object away will open the screen again.
The following example shows how proximity sensing is handled on the iphone. His code uses the Uidevice class to switch proximity monitoring, and subscribes to Uideviceproximitystatedidchangenotification to capture state changes. Both states are on and off. When the Uidevice Proximitystate property returns Yes, the proximity sensor is activated.
2 "Monitoring battery status
Device-specific development for IOS: Check device proximity and battery status