How to send real growl messages with javascript?
Asked Answered
S

9

19

Is it possible to post growl notifications to a user's computer, from a web application, using javascript? This will be only on an intranet application so security is not a major concern. Additionally it will be limited to only Mac users with Safari or Firefox.

Thanks.

Seda answered 18/9, 2009 at 16:15 Comment(1)
alert('grrrr..')Sapwood
B
7

Growl has a network interface, and HTML 5 has Web Sockets, so in theory it might be possible entirely in JavaScript (when Web Sockets are implemented). More realistically, if your webserver is connected to the same network as your clients (i.e. can see and connect to their individual IP addresses), you could do an AJAX style callback to a script on the server that will make the network request.

Britnibrito answered 18/9, 2009 at 16:23 Comment(1)
Your 'network interface' link is broken. Also, the growl protocol has changed. There's a new cross platform protocol called GNTP.Jarietta
P
3

Google Gears has an experimental support for Growl notifications.

Portwine answered 19/9, 2009 at 0:34 Comment(0)
A
3

Fluid, a site-specific browser generator for Mac, exposes a JavaScript Growl notification API [1]:

window.fluid.showGrowlNotification({
    title: "title", 
    description: "description", 
    priority: 1, 
    sticky: false,
    identifier: "foo",
    onclick: callbackFunc,
    icon: imgEl // or URL string
})

Relevant source is on the Fluid Developer page.

You can search for real-world examples at userscripts.org.

One downside with this approach is, of course, you have to force your users to use a Fluid browser when accessing the intranet application.

Setting up a bridge like Adam suggests has the advantage of requiring minimum effort from the users.

Agathaagathe answered 19/4, 2011 at 22:15 Comment(1)
Fluid is pretty nice actually. Though you are right. It requires an action on the user's part so it's not ideal, but good to have options.Jarietta
J
2

I tried to come up with a solution for sending growl message with javascript, with no luck, sadly. I'll summarize my research for future reference.

Possible solutions investigated:

  • Flash - due to flash having access to regular socket connections it seemed like a good idea to come up with a flash snippet that would expose some API to javascript via ExternalInterface. Flash object would be served from website server (remote location) and try to communicate to local growl interface, that would trigger checking cross-domain policy file. That involves communication that isn't understood (supported) by growl service for now, so connection would fail. As an extra info: growl for windows had support for flash based clients but judging from this recent discussion its broken in current version).

  • WebSockets - similar to flash-based idea, websockets require initial exchanging couple of http requests/responses before the connection is upgraded to regular two-way socket connection. As in Flash approach, that would work, but require growl to support that initial http based communication prior to socket connection. Growl doesn't support that for now, some say it might, once the specification for growl is final.

  • Google Gears - Haven't tested it, but google gears has been discontinued as of march 2011, probably raising issues with supporting Firefox in version >= 4.

Junko answered 17/11, 2011 at 8:45 Comment(4)
Thanks for the effort anyway. =] My biggest question is still how to prompt the user's growl client to accept notifications. I assume you can't really use javascript alone, but maybe javascript could talk to a server, which then talks to the client using GNTP. I think if you know the IP address of the client, you can prompt the client to accept notifications from the server, but I don't know where to look for an example of that. Growl documentation might have something but I don't know where to look.Jarietta
Well, if I recall correctly, password can be send to authenticate with growl without the growl prompting for it. So if you're willing and able to use separate server that has access to all computers in your local network (and know how to associate web application user with specific IP address - which should be easy to do), you can get password from user in your web application using any method you want (it may be plain old form) which would be transfered to your web server, which in turn would use it to authenticate with growl and send any notification you want directly to client machine.Junko
Two more thoughts on that subject. I'm 90% sure, that solution with separate web server would work. On server side, you can use one of available libraries that implement GNTP protocol. Here's a list growlforwindows.com/gfw/developers.aspx#integrationJunko
+1 for all that work and reporting back. Saves a lot of time.Whitmer
G
1

The post http://ajaxian.com/archives/growls-for-windows-and-a-web-notification-api contains a link to a growl.js which was written to work with Growl for Windows. I haven't looked into it enough to know whether a similar approach would work with Growl.

Goidelic answered 22/12, 2010 at 19:48 Comment(1)
That solution involves having local server. (Which is feasible in that case, since author is also a developer of growl-for-windows.)Kirtle
D
0

For client-only methods, I've tried the following:

If using Growl for Windows or Growl version 1.3+, you can use the Flash binary as illustrated in this demo page

There also is a chrome-extension made by GfW that uses the binary as NPAPI natively. GrowlChrome
These are based on GNTP protocol which was developed by GfW, and the original Growl (for Mac) projected adopted it from version 1.3

For version 1.2.x, I found another chrome-extension that works: Twitter Notifier and Growl Notifier for Google Play . These extensions are based on JSGrowl

Links

Duff answered 28/6, 2012 at 7:6 Comment(0)
D
0

You could also try Gritter, "a growl-like notification for jQuery."

Delorasdelorenzo answered 8/11, 2012 at 22:27 Comment(0)
P
0

Another poster mentioned it, but you definitely can use Javascript (with a small helping of Flash, but you dont have to mess with that part) to send notifications to Growl running locally. Here is a test page to try it out without setting anything up: http://www.growlforwindows.com/gfw/examples/js/

Note however, this only currently works on Windows. As an earlier poster noted, the Mac version's support for Flash-based connections is currently broken.

On Windows, you can also use WebSockets, and here is a similar test page: http://www.growlforwindows.com/gfw/examples/websocket/

Note that this too is currently not implemented in Growl on the Mac, so if you are targeting Mac users (which it sounds like you are), these probably dont help. Just wanted to point out that both Javascript and WebSockets are possibilities once the support is fully added to the OSX client.

Putandtake answered 11/12, 2012 at 4:10 Comment(0)
A
0

If your users have flash, you can borrow the javascript-flash-growl bridge from here. You can always check the script insides of the flash with something like JPEXS.

I've personally successfully used it and jQuery to setup some custom notifications for myself using mediawiki and using tampermonkey/greasemonkey. The only issues come if flash is blocked/disallowed/not installed, or when flash crashes.

Atavism answered 26/8, 2014 at 14:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.