3

My application is an Agent (doesn't show up in dock) until one specific window is shown, before showing that window I set the following to let the dock display the icon:

NSApp.setActivationPolicy(.regular)

When the window gets closed I set the following to hide the icon from the dock:

NSApp.setActivationPolicy(.accessory)

It works on most of the machines, however on others the app icon stays in dock in 'Recent' section with no 'active' indicator. I can manually remove it via right click and selecting 'remove from dock' but it appears again the next time the window is open. Is it even a 'Recent' section? What's the API to either remove the app from there or prevent it from being added to dock when it's open? Thank you!

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Ruzard
  • 1,167
  • 3
  • 16
  • 33
  • Why do you need to change to NSApplicationActivationPolicyRegular? This is the reason why it's displayed in the dock. Only non sandboxed apps can modify preferences of Dock – Marek H Sep 12 '21 at 17:39
  • @MarekH I change it to NSApplicationActivationPolicyRegular so the app appears in dock when the window is shown. However when it's closed - i set it back to .accessory, because part of it is still running but I don't want the icon to stay in dock forever. The problem is that the icon remains visible in a 'recent' section no matter what activation policy it has. – Ruzard Oct 01 '21 at 19:03

0 Answers0