Using the Ambient Light Sensor for other purposes


We are looking to use the Ambient Light Sensor on iOS. It seems that there is a public API in the IOKit framework, however it has a disclaimer at the top that says "Although it is a public framework, Apple discourages developers from using it, and any apps using it will be rejected from App Store."


Looking at other forum posts, most people want to use the Light Sensor in order to adjust the brightness. Adjusting brightness will definitely get your App rejected by the App Store. What we are wondering is, will Apple reject any App that uses the light sensor, or only those Apps that use the light sensor to adjust the brightness?

Replies

From my reading, Apple does not want us to play with the brightness


I found a lot of interesting information here :

h ttps://stackoverflow.com/questions/6309643/reading-the-iphones-ambient-light-sensor:

"According to this page, … , apple will remove your application from the app store if you attempt to mess with the brightness. I would really just like to change color schemes based on how much brightness the phone detects."


However, I've downloaded apps that set the brghtness to a maximum (to display a QR Code and ease machine reading).

To be clear, there is no public API for reading the ambient light sensor on iOS. I have more to say about this on this thread.

It seems that there is a public API in the IOKit framework …

I/O Kit is not a public API on iOS but, even if it were, you can still get into trouble reading undocumented keys out of the I/O Registry. You can find a classic example of this linked to by the thread referenced above.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Strangely enough, there is API to explicitly set brightness of the screen, however that setting is only active while your app is in the foreground. Indeed, for apps like scanners and card wallet type things, they need this functionality to work.
However there's no other support for using this type of thing, for some unknown reason - other than using the camera or the nebulous IOKit

Yes, but is is clearly a temporary setting.


I guess the reason is to avoid someone manipulating brightness in the back of the user, which could at least distract him/her, let think there is a hardware problem, immediately attracting attention from a very bright screen, drain on battery… All leading to a poor user experience