Disable/Enable the Idle Timer

I would like to disable the idle timer when my app is in the foreground so that the device doesn’t auto lock, as apps such as Dropbox do. In Swift/Ob-C this is just a property of the UIApplication class. Has anybody ever come across the declare for this?

@jean-paul devulder - that is a cherry of a code snippet. I’ve been wondering about such and never knew quite what to ask (so thanks also to @Jason Tait ). For a specific app that we’ve produced for many years, we’ve simply instructed he user to disable sleep. This will solve that as some users are reticent about changing that setting.

Now that I’ve compartmentalized what to look for, I’m off to track down similar options for Linux and Windows. If any of you are keeping such secrets -especially for Linux, please add to this thread and save me the frustration of digging through the GTK+ SDK documentation (as it is).

Bravo @jean-paul devulder !! :slight_smile:

FYI, on the Mac, you can also use a shell command, caffeinate. See the man page for details, but the process would be to create an interactive Shell that calls caffeinate when your apps is activated, and kill the Shell when deactivated. (In theory, don’t think I’ve tried this in Xojo.)

I’m not recommending this as a superior solution, merely an alternate one.

in iOS, there is no shell, and no way to launch any helper of any kind. Everything must be done inside the app. One of the joys of the platform :wink:

D’oh! How many times am I going to miss the fact that I’m in an “iOS” forum?!?


[quote=247080:@Kem Tekinay]D’oh! How many times am I going to miss the fact that I’m in an “iOS” forum?!?


It’s alright Kem.

I’m as guilty as Kem here regarding the iOS nature of Jason’s post. It turns out that my test code had utilized caffeinate at the startup of my script suite and I’d forgotten and that’s why the idle counter didn’t update while my backend was running… :confused: