1

The sample menu bar app is a agent as its LSUIElement is TRUE. I want to prevent logout on certain conditions.

I tried with - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender. But I never receive this message when user logs out.

But without , I am able to prevent logout as well.

Need an alternative solution so as to prevent logout.

1 Answer 1

0

Do not use LSUIElement in the plist. Instead on launch use:

[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];

I verified that applicationShouldTerminate: is in fact called when done this way.

3
  • applicationShouldTerminate: is in fact getting called when we trying to quit menu bar app using commadn+q. Nothing is preventing the logout. NSApplicationActivationPolicyAccessory is in fact equivalent to LSUIElement set to 1 in Info.plist.
    – sac
    Apr 29, 2014 at 10:23
  • applicationShouldTerminate: is in fact getting called for me on logout. However, I am unable to prevent the logout. Apr 30, 2014 at 5:33
  • Any other ways to prevent logout or do a graceful exit. My App is launch agent with LSUIElement =1 .
    – sac
    May 5, 2014 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.