How do I prevent an iOS device from going to sleep mode?

iOSApps/ApplicationsMobile Development

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.

Preventing iOS Device from going to sleep is easy, navigate to your Settings → Display & Brightness → Autolock, select never.

This will never lock your screen.

If you’re developing an iOS Application and you’re required to implement this feature, you should use isidletimerdisabled provided by apple, to read more about it https://developer.apple.com/documentation/uikit/uiapplication/1623070-isidletimerdisabled

In your viewDidLoad method write the following line of code to prevent the device from going to sleep.

UIApplication.shared.isIdleTimerDisabled = true
raja
Published on 29-Jul-2019 14:13:20
Advertisements