Lock macbook screen from isolated application

I am creating a mac application that I want to distribute in the Mac app store. I need this app to have a screen lock feature.

I have 2 different approaches, the problem is that as soon as I turn on the sandbox for the application (which is required for the Mac app store), none of these approaches will work.

Do you know what legal requirement I need to request? Or do you know a third approach that will work with the sandbox?

thanks

Approach 1 using CGSession (fast):

var arguments = ["-suspend"] var task = NSTask() task.arguments = arguments task.launchPath = "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" task.launch() 

Approach 2 using IORequestIdle (fast):

 var r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler") if (r > 0) { IORegistryEntrySetCFProperty(r, "IORequestIdle", kCFBooleanTrue) IOObjectRelease(r) } 
+5
source share
1 answer

Sorry this is not possible. The purpose of the sandbox is to prevent the application from accepting the entire computer.

You can try to get a temporary exception through the channels documented in the sandbox manual.

0
source

Source: https://habr.com/ru/post/1206338/


All Articles