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.

Andrew
  • 196,883
  • 184
  • 487
  • 673
Louis W
  • 2,950
  • 5
  • 39
  • 70

9 Answers9

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.

Adam Wright
  • 47,483
  • 11
  • 126
  • 149
  • 1
    Your 'network interface' link is broken. Also, the growl protocol has changed. There's a new cross platform protocol called GNTP. – Andrew Nov 10 '11 at 04:46
3

Google Gears has an experimental support for Growl notifications.

kangax
  • 37,379
  • 12
  • 94
  • 132
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.

Andrew
  • 196,883
  • 184
  • 487
  • 673
ento
  • 5,613
  • 5
  • 49
  • 68
  • 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. – Andrew Nov 19 '11 at 07:05
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.

WTK
  • 15,360
  • 6
  • 31
  • 42
  • 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. – Andrew Nov 17 '11 at 16:19
  • 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. – WTK Nov 17 '11 at 18:54
  • 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 http://www.growlforwindows.com/gfw/developers.aspx#integration – WTK Nov 17 '11 at 19:07
  • +1 for all that work and reporting back. Saves a lot of time. – IAmNaN Apr 24 '13 at 16:26
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.

Michael Hellein
  • 3,468
  • 1
  • 23
  • 21
  • That solution involves having local server. (Which is feasible in that case, since author is also a developer of growl-for-windows.) – Nikita Rybak Jul 27 '11 at 07:20
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

Himanshu Jansari
  • 28,446
  • 26
  • 101
  • 128
Jang-hwan Kim
  • 838
  • 1
  • 7
  • 11
0

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

Stephen Lead
  • 1,488
  • 4
  • 18
  • 37
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.

briandunnington
  • 423
  • 2
  • 9
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.