What should I do if I want my app to stay active even when user doesn't touch the screen?
Screen dims and divice locks after 30s, 1m, 2m, etc. (depending on settings).
What should I do if I want my app to stay active even when user doesn't touch the screen?
Screen dims and divice locks after 30s, 1m, 2m, etc. (depending on settings).
Do you want to keep screen active (not dimming) ?
Try
UIApplication.shared.isIdleTimerDisabled = true
But that'd have a bad effect on battery !
isIdleTimerDisabled
A Boolean value that controls whether the idle timer is disabled for the app.
Discussion
The default value of this property is
false
. When most apps have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power. However, apps that don't have user input except for the accelerometer—games, for instance—can, by setting this property to true
, disable the “idle timer” to avert system sleep.
Do you want to keep screen active (not dimming) ?
Try
UIApplication.shared.isIdleTimerDisabled = true
But that'd have a bad effect on battery !
isIdleTimerDisabled
A Boolean value that controls whether the idle timer is disabled for the app.
Discussion
The default value of this property is
false
. When most apps have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power. However, apps that don't have user input except for the accelerometer—games, for instance—can, by setting this property to true
, disable the “idle timer” to avert system sleep.
It works! Thank you very much!
Hi @Claude31,
In my case, I would like to disable auto-lock only when user is watching the video (like Netflix/ YouTube). Other than that, I would like to enable it all the time, so how do I do that?
Please let me know!
Thanks