Can I determine if the user disallowed my menubar item?

My app already has UI that allows the user to show/hide a menubar icon. If the user disallows my app's icon via System Settings > Menu Bar > Allow in the menu bar, I'd like to customize my own UI to reflect that. Does macOS provide a way for me to determine the "Allow in the menu bar" state for my application?

Answered by DTS Engineer in 844384022

I asked about this internally and learnt something new (-: The answer to your direct question:

Written by bombich in 788101021
Does macOS provide a way for me to determine the "Allow in the menu bar" state for my application?

is “No.” So far, so expected!

However, NSStatusItem supports a removalAllowed property. Once you set that the user can remove your status item without need of this System Settings control. Your app can observe the removal using KVO, as called out in the docs.

I’ve not had a chance to try this myself yet, but it seems like a good path forward.

Share and Enjoy

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

Accepted Answer

I asked about this internally and learnt something new (-: The answer to your direct question:

Written by bombich in 788101021
Does macOS provide a way for me to determine the "Allow in the menu bar" state for my application?

is “No.” So far, so expected!

However, NSStatusItem supports a removalAllowed property. Once you set that the user can remove your status item without need of this System Settings control. Your app can observe the removal using KVO, as called out in the docs.

I’ve not had a chance to try this myself yet, but it seems like a good path forward.

Share and Enjoy

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

Thanks Quinn, the "NSStatusItemBehaviorRemovalAllowed" behavior is definitely helpful; I have implemented that for my next update. I also filed some feedback to expose the Allow in the Menu Bar preference:

FB18341478: Expose "Allow in the Menu Bar" preference via NSStatusItem

Can I determine if the user disallowed my menubar item?
 
 
Q