Mac Mountain Lion send notification from CLI app
I found that NSUserNotificationCenter
works when [[NSBundle mainBundle] bundleIdentifier]
returns the proper identifier. So, I wrote some swizzling code that you can find at https://github.com/norio-nomura/usernotification
It can send an NSUserNotification
without an Application Bundle.
While I haven't found any specific documentation on this, I assume that you need to be an application (bundle) to deliver notifications. Note that the Notification Center UI always shows the name and icon of the app from which a notification came. That wouldn't be possible with a command-line tool.
Code-signing doesn't seem to be required though.
Perhaps you could write a helper app that just delivers the notifications and just communicate with your helper app from your command-line tool (e.g. using NSDistributedNotificationCenter
).