Add this line of code to the application delegate:
Objective-C:
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Swift 2:
UIApplication.sharedApplication().idleTimerDisabled = true
Swift 3:
UIApplication.shared.isIdleTimerDisabled = true
Iñigo Beitia Aug 08 2018-10-10T00: 00Z
source share