Skip to content

iOS Prevent screen lock on my app

Platform License

Objective-C:

[[UIApplication sharedApplication] setIdleTimerDisabled: YES];

Swift 2.0:

UIApplication.sharedApplication().idleTimerDisabled = true

Swift 3:

UIApplication.shared.isIdleTimerDisabled = true

Here you have two options depending on where you want to invoke the code:

Inside AppDelegate.swift:

application.isIdleTimerDisabled = true

Outside AppDelegate.swift:

UIApplication.shared.isIdleTimerDisabled = true

Let's grow together 🌱

Cheers 🍻