I'm trying to detect screen lock in iphone with swift code UIScreen.main.brightness
value to get current brightness of screen. I am using it inside applicationDidEnterBackground
method.
At lock screen (by pushing lock button), brightness value is 0.0 and at pushing app to background (by pushing home button) the value of brightness is greater than zero.
95% of the times results are good however there occurs some instances when brightness value on lock screen is greater than zero. Maybe because inside applicationDidEnterBackground
the value of brightness is calculated before screen is actually locked in rare occasions.
Does anyone know how to handle this situation gracefully?