How can I prevent the display on an iOS device from dimming and turning off?
IphoneIpadScreenIosIphone Problem Overview
I'm diving into iOS development and am building my own alarm clock app to become familiar with platform and SDK. I've noticed some alarm clock apps in the app store keep the screen from dimming and/or turning off when their app is running. How is this implemented?
Iphone Solutions
Solution 1 - Iphone
Add this line of code on your application delegate:
Objective-C:
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Swift 2:
UIApplication.sharedApplication().idleTimerDisabled = true
Swift 3, 4 & 5:
UIApplication.shared.isIdleTimerDisabled = true