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) }
source share