It used to be the case that the proximity sensor was a private API, but after quite a bit of outcry, Apple made it a public API.
With the UIDevice
API, you're able to query the proximity sensor for your needs, as documented in the link you've provided.