Blocking app quit

Hello, I'm currently coding a productivity app which help user to focus while studying through restricting access to website and app they have selected, however for now, they can really easily make this uselles trhough quitting the app using command + Q or force quit the app in the activity monitor. Do you know how could I block user to quit the app while she is running, and it is allowed by apple guideline ?

Answered by DTS Engineer in 829497022

It is possible for a macOS to not terminate when asked. See the applicationWillTerminate(_:) delegate method.

However, as darkpaw notes, this is quite worrying from an HI perspective. Users expect apps to quit when asked. Moreover, by not quitting you’ll also prevent both shutdown and restart.

Also, there’s no good way to prevent Force Quit.

macOS has a built-in system for letting users stay focused, namely Focus. I recommend that you explore ways of integrating into that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It is a terrible user experience to stop someone from quitting an app, and you should not do this.

Just write your app as though someone who wants to use it is going to leave it running.

If I installed your app, launched it, and then couldn't quit it, it would be immediately moved to the trash, and I'd likely never use anything you ever developed in future.

It is possible for a macOS to not terminate when asked. See the applicationWillTerminate(_:) delegate method.

However, as darkpaw notes, this is quite worrying from an HI perspective. Users expect apps to quit when asked. Moreover, by not quitting you’ll also prevent both shutdown and restart.

Also, there’s no good way to prevent Force Quit.

macOS has a built-in system for letting users stay focused, namely Focus. I recommend that you explore ways of integrating into that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Blocking app quit
 
 
Q