detecting if iPhone is in a dark room

后端 未结 6 1620
独厮守ぢ
独厮守ぢ 2020-11-30 03:40

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

6条回答
  •  心在旅途
    2020-11-30 04:04

    Proximity sensor is not what you should be looking for. Ambient light sensor it is. Apparently that API is undocumented or not available at all for developers. An alternative way of detecting if iPhone is in a dark room would be using the camera and obtaining the luminosity . Here's a good guide on how to do that,

    https://www.transpire.com/insights/blog/obtaining-luminosity-ios-camera/

提交回复
热议问题