How to prevent the screen from sleeping in iOS

Screen dimming getting on your nerves? That rancid 5min timeout not enough for testing, or does your app need to stay awake while it’s in the foreground?

Fear not, UIApplication has a parameter we can set to prevent an app from going to sleep, or the screen from going dark. We can set this anywhere in our app:

To make the display adhere to whatever the user has set again, simply change the parameter back to NO.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.