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.

sac
  • 890
  • 6
  • 19

1 Answers1

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.

user3555093
  • 316
  • 2
  • 2
  • 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 '14 at 10:23
  • applicationShouldTerminate: is in fact getting called for me on logout. However, I am unable to prevent the logout. – user3555093 Apr 30 '14 at 05:33
  • Any other ways to prevent logout or do a graceful exit. My App is launch agent with LSUIElement =1 . – sac May 05 '14 at 05:46