Mac OS LSUIElement app does not display notifications

I made a simple applescript app to run a shell script and display a notification when it ends, it runs pretty well but I did't want the app appearing in the dock, so I added LSUIElement = true in the info.plist, and now the script runs but the app does not notify. Is there a way to have a background app (does not appear in the dock) with the ability to display notifications?

Answered by RomVA in 811312022

use the following in your .plist instead

<key>LSBackgroundOnly</key>
<integer>1</integer>

And check Notification Center settings specifically for your applet. While editing your applet, de editor is the one sending the notifications. While running the applet, it's the applet who sends the notifications. So, maybe that's why it works while editing but not when you run the applet.

Accepted Answer

use the following in your .plist instead

<key>LSBackgroundOnly</key>
<integer>1</integer>

And check Notification Center settings specifically for your applet. While editing your applet, de editor is the one sending the notifications. While running the applet, it's the applet who sends the notifications. So, maybe that's why it works while editing but not when you run the applet.

Thanks @RomVA RomVA for the response, to be honest, your solution did work, but I managed to achieve another one, I forgot to post here, but it may be useful for other people. I just changed

display notification "Foo foo" with title "Foo"

for

tell application "System Events"
	display notification "Foo foo" with title "Foo"
end tell

it asks for permission to send an event to the system but it works just like your solution

Mac OS LSUIElement app does not display notifications
 
 
Q