Page 1 of 1

Receive notifications from *another application*?

Posted: Fri Nov 28, 2008 4:28 pm
by jameswfrost
Hi there,

I was wondering if there was any way to intercept Growl notifications? Or, to receive notifications posted by another application?
I have a music playing application that posts Growl notifications when the song changes - I'd like to be able to grab the titles and artists of the songs in the notifications, so I can do other things with them.

Is this at all possible?

Re: Receive notifications from *another application*?

Posted: Sat Nov 29, 2008 2:08 am
by Diggory
A bit of a hack - and probably not recommended - but you could use Notification Watcher to observe the pattern of Growl notifications in the NSDistributedNotification system.

Your code could then observe Growl notifications based on your criteria using the NSDistributedNotification Class.

Again - remember that this would be a hack and may not reliable or recommended.

Re: Receive notifications from *another application*?

Posted: Thu Dec 11, 2008 8:28 pm
by originalpete
I'm also interested in this.

I'm trying to get the raw growl notifications out of Skype on OSX. Skype is set up with Growl, and I get the usual growl popups when people sign in/out and for all other Skype events.

As you suggested, I used the NotificationWatcher tool to monitor messages. But I only see NSConcreteNotifications if:
a) I click on a growl notification or,
b) the notification times out.

There are no notifications generated for the initial broadcast from Skype to Growl. Which means I'm trying to hook my notification monitor into the wrong place. This seems to indicate that applications don't talk _to_ growl using the NSNotificationCenter. Is this correct?

Please advise.

Re: Receive notifications from *another application*?

Posted: Fri Dec 12, 2008 12:24 pm
by originalpete
Ok, I'm getting closer:

Turns out that if Growl is running, I don't see the notifications in NotificationWatcher. I wrote my own simple watcher using MacRuby with the new on_notification mapping from HotCocoa, and witnessed similar behaviour.

When Growl is running it swallows up the notification and I can't see it. When growl is off, the GrowlNotifications from Skype are processed by my watcher script.

So, how can I get both? It must be possible to attach my observers to NSDistributedNotificationCenter.defaultCenter in such a way that it can see notifications that are being observed by Growl. Any ideas how?

P.

Re: Receive notifications from *another application*?

Posted: Fri Dec 12, 2008 4:09 pm
by The_Tick
Growl doesn't use notification center except as a backup communication method anymore. I think this is the wrong tree.

We added code a long time back to allow for a dashboard widget to get notifications from Growl. If that's still in place, you could go that route.