4 Replies
      Latest reply on Dec 15, 2018 9:02 AM by Claude31
      Alexanderfrombergen Level 1 Level 1 (0 points)

         

        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?

        • Re: Using the Ambient Light Sensor for other purposes
          Claude31 Level 8 Level 8 (6,205 points)

          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).

            • Re: Using the Ambient Light Sensor for other purposes
              AppetiserDev Level 1 Level 1 (0 points)

              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



            • Re: Using the Ambient Light Sensor for other purposes
              eskimo Apple Staff Apple Staff (11,485 points)

              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"