I am working on a Swift 3 application that will be running on a device indefinitely. This is highly stressful to the device and I would like to turn the display off until I trigger an event to turn it back on.
I can set isProximityMonitoringEnabled to keep the device screen off and application running in background with the sensor covered. However, the screen doesn't turn back on when I set it to false (It doesn't even turn on if I segue to another view programmatically) until I take off the cover.
UIDevice.current.isProximityMonitoringEnabled = true;
As of now, I am reducing screen brightness to 0.0 when its in idle.
UIScreen.main.brightness = CGFloat(0.0)
I do not mind using Private API's like the answer on here https://stackoverflow.com/a/12944387/1509698 says. But for the life of me I can't convert that to Swift or find a code snippet working on iOS 10.