Desktop Notifications

This is a feature that may come to a browser some day.  I am interesting in your thoughts:

Desktop Notifications

Desktop notifications allow a web page to notify the user using system level services, such as Growl, in a clean, safe, and easy to use manner.

The code is very simple:

navigator.notification.notify("Another Desktop Notification",
                              "Check out my icon",
                              "http://dougt.org/me.jpg");

and the result is something you’d expect from a notification.  On the Mac, the notification may look like:

You can get more sophisticated by adding a callback when the user clicks on the Desktop Notification:

navigator.notification.notify("Another Desktop Notification",
                              "Check out my icon",
                              "http://dougt.org/me.jpg");
                              function() { /*do something*/ });

A user must grant each site permission before they can use Desktop Notifications.  We will use the familiar notification bar (the text isn’t final.  Also, these will end up looking quite different in future releases of Firefox.):

That is there all there is to it!

Get involved:

If you like or dislike this feature, please just leave a comment.

If you like to follow the implementation details, you can follow bug 573588.

You can try out the engineering builds.  There are bound to be a few bugz.  If you see anything funky, please let me know.

If you are using the above engineering builds, you can try out Desktop Notifications.

More details:

I reviewed two draft specifications.  The first is the WebNotification specification and the other is the Google Gears NotificationAPI.  I found both of these APIs more complex than what was required.  Clearly both of these other APIs have use cases that are not address by my proposal.  But for basic notification from the browser, not much is required.

Looking at what Growl and other system level notification services provide, you basically only need a title, a description, and an icon.  For fun, I added one callback if the user clicks on the notification while it is on screen.

Next Steps

You tell me.  Is this something you’d like to see in the browser?  Does the API work for your use cases?

Let me know what you think!

This entry was posted in General, mozilla and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

51 Comments

  1. Nimrod
    Posted June 21, 2010 at 11:47 pm | Permalink

    I really like this feature and as an extension developer I will definitely use it.

    I would like to be able to use it from extensions without the notification bar (or at least with a different notification) also it would be really cool if I could use links inside the notification text, supporting some basic html like tag would solve this.

  2. Daniel Glazman
    Posted June 21, 2010 at 11:53 pm | Permalink

    I love it but I am afraid it could be used by web sites to show ads in an unblockable way. So the browser should offer the user a way to control these notifications. On Mac, the Growl helper app can do it for you but too many people don’t really know how to handle it ; on Windows and Linux, there’s no real way to control notifications so that’s a task for the browser.
    In summary: you have to be extra careful about the balance between usefulness for sites like Gmail or internet fora and the annoyance of sites that will push advertisement that way…

    • Posted June 21, 2010 at 11:58 pm | Permalink

      Hey Glaz!

      I share your concern completely. I want Twitter and http://www.glazman.org to be able to use it, but no one else!

      The current idea is to use exactly the same mechanism that protects geolocation. It will be like many things we do — Default Off, Opt-In per site to enable, and in total control by the user at all times.

      • Daniel Glazman
        Posted June 22, 2010 at 12:11 am | Permalink

        When I say “find the balance”, I have specifically in mind the following use case:

        - the web site is really dynamic and has really interesting notifs to push to the user
        - but it also sends ads through notifications

        The user has then the choice to block the web site’s notifs and miss real notifs, allow everything and then be annoyed by ads. That’s why I recommend you add a “realm” parameter to your method, allowing the web site to “specify” a bit more a notification. The user could then allow “incoming message” notifs and forbid “sponsored ads” notifs. Just thinking at loud here but it could be a solution to the problem.

        • Posted June 22, 2010 at 12:14 am | Permalink

          I like YouTube, but I hate the ads they place at the beginning of some clips…. I like so-and-so’s RSS, but I hate seeing the ads in it.

          If a site, that you permitted, uses desktop notifications to deliver ads, then you just disable it for that site… and find some other service that offers a better user experience.

          • Daniel Glazman
            Posted June 22, 2010 at 12:18 am | Permalink

            Unfortunately, that’s not always doable and from time to time you just can’t change the service because your current work relies on a given one. So my solution above at least offers web sites a possibility to be virtuous or at least clean.

  3. jrk
    Posted June 22, 2010 at 12:12 am | Permalink

    Implement what Chrome already does…

    • Posted June 22, 2010 at 12:41 am | Permalink

      Maybe! One of the last paragraphs of the post, I discussed why I didn’t just use their draft specification.

      Lets see if we can get these two APIs similar enough for interop.

  4. Posted June 22, 2010 at 12:13 am | Permalink

    Hi Doug,
    this looks like the ultimate spam tool for web pages. Instead of annoying pop-ups, you will have your desktop filled with nice notifications of new products and services (only the best of the world ;)
    While I think it is useful to consider desktop notices as an additional user interface for the browser, I think there are a lot of security precautions to be taken. I would look into the history of pop-up development as there are a lot of parallel issues.
    In turn, I could imagine that such notifications are used by the browser itself for cookie notifications, privacy dashboard messages and the like. Have you thought about that? The other thing is that notifications may not work correctly on mobile devices, so web pages should not rely on those for critical information.

    See: http://www.w3.org/2010/api-privacy-ws/

    Best,

    Rigo

    • Posted June 22, 2010 at 12:25 am | Permalink

      Hi Rigo!

      Firefox uses these notifications for things like “Download completed.” I spoke to the UX people working on Mobile and I think we will continue to see use of the notification service for application specific notifications.

      For notifications from the web, as I mentioned in the post…. it is going to be default off, opt-in per site, and easy to turn off. I’d imagine that it would be useful for things like Twitter and web mail services — both have an incentive to get you to go back to the site and not so much to directly advertise in the notification.

      And sorry I will be missing the w3c privacy meeting…. I am looking forward to reading the minutes.

  5. Posted June 22, 2010 at 12:21 am | Permalink

    Showing notifications can be a bit tricky when bidi text is involved. How can we make sure to display alerts in RTL in case the web page or application is in the set of right-to-left languages? This is similar to the messing window title bar, but in this case we have better control over the way we get it displayed, as we can make sure the API support these flags from the very beginning.

    • Posted June 22, 2010 at 12:28 am | Permalink

      We receive a Unicode string from Javascript and pass it along (unmodified) to the system alert implementation. If the system implementation supports BIDI, it should all magically just work ™!. If not, we have a bug. Do you know if Growl and other services are BIDI aware? What about Android?

    • Daniel Glazman
      Posted June 22, 2010 at 12:36 am | Permalink

      It should just work (at least on Mac OS X and windows). I am already using Growl notifs in a mac xulrunner-based app that uses exactly the same underlying code than dougt’s proposed notification system, and I can display yiddish and hebrew notifications w/o problem. On windows, same thing, I perfectly saw the yiddish text (and since I can read it, I confirm it was displayed ok). No idea on linux I never tried.

      • Posted June 22, 2010 at 12:41 am | Permalink

        Are you sure it changes the text alignment as well as the embedded direction? Because RLE..PDF won’t be the best solution for this.

        • Posted June 22, 2010 at 12:45 am | Permalink

          Tomer,
          The idea behind this is to hand off the notification to a system service — not build a dialog or application that handles notifications. In the systems that I reviewed, none had a parameter or obvious way to hint that the text was in BIDI. I wish I knew more about these issues, but from what I saw, there wasn’t a clear way of doing what you are asking for.

          In the case where Firefox provides its own UI (like on the mac when you don’t have Growl), maybe that is something we can support?

  6. Simon
    Posted June 22, 2010 at 12:51 am | Permalink

    I dare say that single-direction RTL text displays fine – the question is what happens with mixed direction text.

    There doesn’t seem to be any direction parameter in the Growl API (I haven’t looked at other services yet), so it probably just follows the directionality of the desktop.

  7. Posted June 22, 2010 at 3:35 am | Permalink

    I think the abundance of ‘notification’ scripts around clearly shows the need for this functionality.

    It would be great to have it.

  8. Tiago Sá
    Posted June 22, 2010 at 4:55 am | Permalink

    Ahh, the tidal torrents of comments :P

    I like this feature a lot, and I think it should be simple, like this. I think your proposal is perfect in every way. No styling from the site is good, the asking the user to allow is good, and the callback function is good (and maybe we could restrict it to very few JS functions, so sites can’t steal info from other tabs and stuff, or maybe we could drop the callback function and simply direct the user to the respective tab on click of the notification).

    We also need a way to dismiss the notification, and another way to dismiss all notifications of this site permanently. Modal buttons should be nice for this, but it may clutter the notification popup a bit, so careful design is necessary.

    Will this make it into Firefox 4.0? It would be fantastic to start using this in extensions (make them consistent), if it doesn’t become a standard right away.

    • Posted June 22, 2010 at 10:01 am | Permalink

      Hi Taigo!

      Great ideas. I think what might be best, as you say, is to get something very simple first. Then we can iterate as the demand for a given feature increases.

      I’d like to see this in Firefox 4.0, but that isn’t just my decision. We first have to get the best API, work out all of the technical decisions, get tests (WOot! for automated test coverage!), UI/UX, localization, etc. Once everything is in place, then we can advocate for the feature in FF.next.

      Thanks again for your thoughts!

  9. AS
    Posted June 22, 2010 at 5:07 am | Permalink

    I love it. My Greasemonkey scripts will finally get that extra little thing they need. How similar is this implementation to the webkit-notifications that Chrome has added?

    • Posted June 22, 2010 at 9:59 am | Permalink

      Thanks As!

      I like it to, and really can’t wait for gmail and twitter to take advantage of something like this.

      The Google spec is pretty close to my proposal. I think my is a bit easier to use as a developer.

  10. Posted June 22, 2010 at 7:44 am | Permalink

    I would really love to see a simple notification system like this; I find the WebKit system too complicated. As Daniel Glazman says, however, it would certainly need some kind of system to stop it being used for pushing unwanted ads.

  11. Tim
    Posted June 22, 2010 at 8:16 am | Permalink

    This reminds me a bit of Aza’s old article on Humanized (http://humanized.com/weblog/2006/09/11/monolog_boxes_and_transparent_messages/). I love the idea… could perhaps be better if it could optionally be channeled through Growl or a better notification program (maybe mozilla could build something small). Something simple that sits in your tray… and you can click on to show a log of recent notifications (similar to how facebook does it on their site).

    If only the OSes had something like this built in… but perhaps you all can show them how useful a universal notification area could be. Thanks for a great! :)

    • Tim
      Posted June 22, 2010 at 8:17 am | Permalink

      A great post, thank you for a great and innovative post. lol

      • Posted June 22, 2010 at 9:55 am | Permalink

        Tim, I did say it was low hanging fruit.

  12. Sander
    Posted June 22, 2010 at 8:36 am | Permalink

    You might want to read this discussion between a Chromium developer and an Ubuntu designer about the UI, maybe even resume the discussion. Ubuntu implements some very nice and thoughtful ideas with respect to not disturbing the user. This would also imply a very simple API as far as I can see.

    • Posted June 22, 2010 at 9:54 am | Permalink

      Got a link?

      • Sander
        Posted June 22, 2010 at 10:57 am | Permalink
        • Posted June 22, 2010 at 11:12 am | Permalink

          Ah, yes. Thanks for this info. I think by default on Ubuntu, Firefox just builds its own UI for notifications… sad. We need to do better! ;-)

          Most system level notification apis don’t deal with mark up at all. Firefox probably could be made to support this type of notification, but I am not sure of the immediate value.

          • Sander
            Posted June 28, 2010 at 1:36 am | Permalink

            I have not read that whole thread myself, but I think the biggest point was whether to support ‘actions’ or not. Ubuntu decided that standard system and app notifications should not have an action button, with valid reasons. So I guess they would argue that websites should not have them either. Ask on that Ayatana mailing list if you want to be convinced to make the Web Notification API incredibly easy. :-)

            I don’t think Ubuntu supports notification markup. It really should be pretty easy to create a notification there, with a single D-Bus call. 

  13. Posted June 22, 2010 at 8:50 am | Permalink

    I’d just add another optional parameter, to specify if the notification is sticky or not. That way, important notifs would wait for the user to dismiss them, while transient ones would just disappear automatically.

    • Posted June 22, 2010 at 9:54 am | Permalink

      This is a neat idea. It is usually up to the system how notifications are presented. For example, there are system setting for how long each notification should stay on screen and if it needs to be clicked to be dismissed. Firefox wouldn’t really have any way to change these without changing these settings for all users.

    • Daniel Glazman
      Posted June 22, 2010 at 1:38 pm | Permalink

      On mac, that’s up to Growl and I am not sure Firefox should do something about it

  14. boxingsquirrel
    Posted June 22, 2010 at 9:21 am | Permalink

    Awesome! Just so long as it’s easy for endusers who aren’t real techsavvy to enable it, I can’t wait! Do you have any idea of the timeline to implement it?

    • Posted June 22, 2010 at 9:52 am | Permalink

      Nope, but hopefully soon. Getting the API right is the most important. I’d like interop with what Chrome has done, but not sure they have the simplest API yet.

  15. Drew Wilson
    Posted June 22, 2010 at 10:15 am | Permalink

    As one of the people who contributed to developing the Web Standards API for desktop notifications, I’m really excited to see Firefox embracing this functionality, but sad to see new implementations that don’t adhere to the standard under development.

    I would highly encourage you to present your alternate proposal to the public-webapps group or whatwg. As you note, there are use cases (some of which relate to privacy and security) that your simpler API does not cover, and we’ll need to find a way to address them as part of the standard API that all browsers can implement.

    • Posted June 22, 2010 at 10:20 am | Permalink

      Hey Drew,

      I completely agree! I am talking to John Gregg (the author of the w3c web notification spec). I do hope for interop and I am not drawing any lines in the sand. :-) I just want this to work and I want it to be as simple as possible for the web developer. What specific use-cases (related to privacy and security) are you think about? I am not sure I see them nor do I see how they were address in WebNotifications.

      • Drew Wilson
        Posted June 22, 2010 at 5:11 pm | Permalink

        As an example, the w3c API contains an explicit requestPermission() API call which applications can use to request permission to display notifications – one reason why we have an explicit API for displaying permissions is so browsers can prevent websites from spamming the user with infobar popups inappropriately – in the case of Chrome, John Gregg requires that requestPermission() be invoked in the context of a a user gesture/mouse click, with the intent that web sites have some explanatory user flow around enabling notifications. If you don’t do this, then every single display ad distributor will start requesting permissions to display notifications (your existing API would allow them to display the permissions infobar even if the user never interacts with the ad in any way).

        In any case, I think it’s great that you’re talking privately with John Gregg, but given the large number of stakeholders in the notifications API (Opera is interested in implementing it, the Qt port of WebKit is also implementing it) I would strongly encourage you (and any other interested parties within Mozilla) to have this discussion openly on the appropriate w3c mailing lists so that everyone can agree on a common API. Sidestepping the standards process may seem expedient in the short-run, but in the long run it just makes it harder to come to consensus on a common API, and leaves Mozilla in a position where they either have to deprecate your current API (possibly breaking websites) or support *both* APIs (your API and the eventual standard) going forward.

        OK, done with my stuffy lecturing :) I really am happy to see this functionality in Firefox – thanks for building this!

        • Posted June 23, 2010 at 9:22 am | Permalink

          Right Drew. I am excited about this too.

          About the requestPermission stuff, it is out-of-scope of a spec like this. It is a really good idea, and I think that we should consider using something like this for geolocation as well! So, we should factor it out of the interface it currently is in, and move it somewhere else. And the thing about only doing a request when the user clicks…. it sounds alot like what we already do for window.open() to stop popups. I tend to think this being an implementation detail and that since this feature is already opt in, maybe it isn’t required.

          Any how, talking in public about this is great. I know the pain and the reward of working with standards bodies. In any case, I will end up posing something to the webapps mailing list.

          Thanks again!

  16. Posted June 22, 2010 at 1:07 pm | Permalink

    I’m glad to see you’re working on this and I’m happy to see so much interest in this feature. It’s definitely a standard that needs to get added soon to all major web browsers. Please don’t make yet another API but try as hard as possible to find a unified agreement between all browser vendors.

    Have you had a chance to checkout Yip? It’s a Firefox extension that does an excellent job of this already. As a web developer I prefer Yip’s syntax, where you pass a JavaScript object to the notification method.

    I’m also not convinced if there should be yet another “allow or disallow notification bar”. I do advocate privacy but it seems as if Firefox has so many of these options that the user has to click on now. I’m not a fan of that.

    http://www.yipyip.com/
    http://abcdefu.wordpress.com/2009/06/09/introducing-yip-an-unified-notification-system-for-the-web/

    • Posted June 22, 2010 at 1:16 pm | Permalink

      Hi Mark,
      Thanks for your comments. I am talking with the editor of WebNotifications… I think that we can get enough stuff together to make something work in both browsers. I do not think it would be a good idea to expose this to web content without a notification. This point is not negotiable.

  17. wdeng
    Posted June 22, 2010 at 7:33 pm | Permalink

    I like this feature very much

  18. Mook
    Posted June 24, 2010 at 1:43 am | Permalink

    And of course I’d find it not complex enough ;) Mostly, for me, it’s having custom actions (as the gears spec calls it) and knowing how the notification was closed. But then again, I was thinking about this from a desktop app point of view anyway, so perhaps limiting what the web can do would be a good thing?

  19. A reader
    Posted June 24, 2010 at 7:02 pm | Permalink

    WebMail notifier does it heatly. Text and link.

    What about implementing something similar into your system? Instead of each website throwing around any notifications it wants, let the website to offer to user a userscript for notifications, which will work and show notifications even when the site is closed, and allow opening this website when notification is interesting.

    Each notification should have browser section (like: it’s userscript with this name from this domain; button “close”) and site section (some HTML they can place into rectangular of such size; links and paragraphs and images (if you really want them) allowed; no CSS style, no JavaScript, no Flash, or there will be some place for mischief or complexity).

    If the userscript shows only ads, user uninstalls it. If it shows both useful information and ads, user may try to modify the script.

    And userscripts can be installed not only from websites, but also from community repository, like AMO.

  20. Pedro Junior
    Posted June 26, 2010 at 1:53 pm | Permalink

    Will support showing html notifications, like Chromium does?

    http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification

    • Posted June 26, 2010 at 2:08 pm | Permalink

      I do not think html notifications is a good idea.

  21. taz
    Posted July 7, 2010 at 11:04 pm | Permalink

    I’m using your latest tryserver build and the demo at http://people.mozilla.org/~dougt/notification.html
    isn’t doing anything for me.

One Trackback

  1. [...] Turner – a platform and mobile engineer with the Mozilla Corporation – has a post up discussing a new feature that may one day come to Firefox: desktop [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>