Is there a way to use the iPhone proximity sensor to detect whether the phone is in a room with no light?
This question seems to imply that this is not possible...Do
Although it is possible to access the ambient light sensor data through IOKit framework, Apple discourages developers from using it, and any apps using it will be rejected from App Store.
But it is possible to deduce the luminosity of the environment approximately through the camera. That is by implementing the camera through AVFoundation framework and processing the meta data coming though each of the camera frames. Refer to this answer on question : How to get light value from AVFoundation