I am looking for a way to authenticate a macOS application that will allow the application to wake a Mac user from sleep.
I know that I can schedule a force event to wake the computer using the same code as provided here .
When I run the IOPMSchedulePowerEvent code, the value is βresultβ in the code below (IORturn result) = -536870207.
IOReturn result = IOPMSchedulePowerEvent(CFBridgingRetain(someCFDate), NULL, CFSTR(kIOPMAutoWake));
After doing some searching and finding someone with a similar problem on this forum post , I'm sure the root of my problem is the need to authenticate the application so that it can wake the Mac user from sleep. I found some of the documentation for the local network for local authentication here , but it still does not seem to fully address my problem.
So in short, how can I provide the application with the authentication needed to wake the Mac from sleep?
Edit: I studied the problem a little more, and I think I have achieved good results.
Firstly, the reason I got kIOReturnNotPrivilegedit was because you have to run the application as root in Xcode. This can be done by editing the debugging scheme through Product> Scheme> Edit Scheme and changing the "Debug Process as" parameter to "Root".
Setting up the application to run as root, I can correctly plan power events to put the computer into sleep mode and wake it up at the appointed time.
It seems that there are some other problems that arise in Xcode 8.3 if your application is isolated and runs as root. I will create another post to ask this question.
source
share