How to make a sandboxed kiosk app?

I have an app that works like a slideshow.
The app works on macOS Catalina, and it is sandboxed.

Now, I would like to provide a mode for running it in "kiosk mode".
Requirements:
  1. Run in fullscreen

  2. Disallow app switching, quitting, etc.

  3. Accept keyboard events

  4. The currently logged in user should be able to gain full access by authenticating themselves.

I have tried to add this code to my AppDelegate:
Code Block objective-c
NSApplicationPresentationOptions presentationOptions =(NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar | NSApplicationPresentationDisableAppleMenu | NSApplicationPresentationDisableProcessSwitching | NSApplicationPresentationDisableForceQuit | NSApplicationPresentationDisableHideApplication );
NSDictionary *fullScreenOptions = @{ NSFullScreenModeApplicationPresentationOptions: @(presentationOptions) };
[self.window.contentView enterFullScreenMode: [NSScreen mainScreen] withOptions: fullScreenOptions ];


It does provide kind of a kiosk mode, but my app does not receive any key events any more.
It does not matter whether I put this code in -awakeFromNib or in -applicationWillFinishLaunching or in -applicationDidFinishLaunching, I always get the "Funk" sound.
Of course, when I omit the above lines of code, everything works fine, i.e., I receive key events as usual.

I could switch to fullscreen just by calling
Code Block
[self.window toggleFullScreen: nil]

but then I don't have the kiosk mode precautions, like preventing the user from switching to other apps.

The second problem I am facing is this:
I would like to allow users to quit the app, provided they can authenticate themselves (requirement #4).
There used to be an API ( https://developer.apple.com/documentation/security/authorization_services ),
but it is not available in a sandboxed app. (I don't get Apple's reasoning, but oh well ...)

Question is: is there any way to achieve what I want?

How to make a sandboxed kiosk app?
 
 
Q