Trying to Achieve
Stop the screen going to sleep on certain View Controller
What I have done
I have tested my app with the following code on a physical iPhone 6 running on iOS 12.1.12. I set the phone Dislpay & Brigthness > Auto-Lock
to 30 seconds. I ran the app and on the particular VC with UIApplication.shared.isIdleTimerDisabled = true
, the screen remains on even after 30 seconds. And when I switch to other VC without UIApplication.shared.isIdleTimerDisabled = true
, the screen will turn off after 30 seconds.
I distributed to AppStore and I am positive that I have uploaded the correct version and dowloaded a fresh copy from AppStore, the screen always on thingy doesn't work at all, the screen will always turn off following the Auto-Lock
setting.
I have read some articles https://docs.kioskproapp.com/article/899-ios-12-with-guided-access-causing-kiosk-pro-to-sleep and isIdleTimerDisabled not working in iOS 12
I tried the Guided Access
and switched on Guided Access
and Mirror Display Auto-Lock > ON
. Still it is not working for the App from AppStore. Please help.
Code
override func viewDidLoad() {
super.viewDidLoad()
//==== For the screen to remains on
UIApplication.shared.isIdleTimerDisabled = true
}
override func viewDidDisappear(_ animated: Bool) {
//=== Switch off the screen always on, back to the phone settings.
UIApplication.shared.isIdleTimerDisabled = false
}