App Nap

If I run this in my program at startup defaults write app.domain.name NSAppSleepDisabled -bool YES
will it get rejected by the App Store or is this allowed?

Thanks

Why would you not set that in the app plist before you sign & package it ?

Norman,

I add this to my plist
NSAppSleepDisabled

But it does not work. The other way works. Not sure why.

Yeah there’s no key to put in the APP plist
defaults write works because it writes to the users “preferences” which are not the same plist as the one in the app
But that probably won’t work in a sandboxed app and it only takes effect on the NEXT launch

You should use NSProcessInfo - but why do you need it at all ?

macOSLib might have declares for this already

Norman,

The application uses a few Threads and Timers, without App Nap it works great. Once App Nap
is turned on it whacks the application.

Okay, I will use NSProcessInfop beginActivityWithOptions and see if that works.

Thanks

We use this in Backup To Go, once a Backup has been started and then release it upon completion. Otherwise Backup To Go explicitly requests App Nap when it’s not doing anything to save battery life.

As a laptop user, I have to say “thanks for doing things correctly”. App Nap is a huge power win and taking a power assertion for the entire life of the application is, at best, unfortunate.

You’re welcome and as a fellow laptop user, I also wanted to save as much juice as possible.

For those of you who are developing background apps, ( UIElement = 1 ) you need to request App Nap functionality, add the following key to the app’s plist.

NSSupportsAppNap = True

Then when you need performance, use the NSProcessInfo to request it and then release it upon completion.

[quote=118085:@George Balla]The application uses a few Threads and Timers, without App Nap it works great. Once App Nap
is turned on it whacks the application.[/quote]
What are you using the timers for and how are you using the timers? One of the ways how Backup To Go can require nothing when idle, is we wait until the system sends us a message, then we wake up and do our business. Depending on what you’re waiting for (via Timers) perhaps there’s another way.[quote=118068:@George Balla]If I run this in my program at startup defaults write app.domain.name NSAppSleepDisabled -bool YES
will it get rejected by the App Store or is this allowed?[/quote]
Can’t say for sure, but maybe as your application having access to defaults might allow it to do things it’s not supposed to. Instead look at NSUserDefaults as this is the correct way to read and write preferences on OS X (and of course is allowed in a Sandboxed application).

Microsoft have their power saving APIs too. InstantGo

Would be great if Xojo could study the possibility of an unified a Xplat set of functions/events for power saving handling.