Accessing the ambient light sensor in iOS

12.9k views Asked by At

I'm working on a project in which it is really necessary to access the ambient light sensor.

I searched a lot in Google and Stackoverflow, but couldn't find any useful information. Is it even possible to do so?

I also tried to calculate the ambient light value by calculating the brightness out of the camera input, but the results aren't really precise, as the camera makes lot's of adjustments to the images, which distort the results.

2

There are 2 answers

3
geekchic On BEST ANSWER

To read the ambient light sensor data, you need to use IOHID in the IOKit framework (Reference)

http://iphonedevwiki.net/index.php/AppleISL29003

http://iphonedevwiki.net/index.php/IOKit.framework

0
Satheesh On

I could be too late to the party but I learn from developer documentation that SensorKit would allow us to do it,

https://developer.apple.com/documentation/sensorkit/srsensor/3377673-ambientlightsensor