My favorites | Sign in
Project Logo
             
Search
for
Updated Jun 10, 2008 by gears.team.jian
Labels: DesignDoc
NotificationAPI  
Providing desktop notifications for web applications.

Summary

The Gears Notificatations APIs are responsible for managing notifications from web applications, and showing them on the user's desktop. Incoming notifications are not displayed when the user is considered not available for the notifications, i.e. the user is away, idle or in full-screen presentation mode.

Notifications are displayed in top-most balloon-styled windows. On Windows, balloons always appear starting in the lower right corner of the primary screen's working area and go upward. On Macs, they start at the upper right corner and proceed downward. The balloons are constrained to ensure that the balloons will not take up more than 75% of the height of the working area.

Example

<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript">
var desktop = google.gears.factory.create('beta.desktop')
var notification = desktop.createNotification();
notification.title = Barbecue on Saturday';
notification.icon = 'http://mail.google.com/mail.gif';
notification.subtitle = 'Thu Mar 27 1:25pm - 2:25pm';
notification.description = 'Hey everyone, looks like great weather this ' +
    'weekend so I thought we might get together';
notification.displayAtTime = new Date(2008, 5, 27, 14, 0, 0);
notification.displayUntilTime = new Date(2008, 5, 27, 14, 0, 15);
notification.addAction('View', 'http://mail.google.com/view?id=...');
desktop.showNotification(notification);
</script>

Details

Notifier functionality in Desktop class

(created by calling google.gears.factory.create('beta.desktop'))

// Creates a notification object.
Notification createNotification()

// Shows a notification. If the notification with the same ID is on display, 
// it will get updated.
// If the notification can be shown successfully, the notification ID will be
// returned. Otherwise, an empty string is returned.
string showNotification(Notification notification)

// Removes the notification with the given ID. If the notification is on display,
// it will get dismissed immediately.
// If the notification with the specified ID can be found, 1 will be returned.
// Otherwise, 0 will be returned.
int removeNotification(string id)

Notification class

/// Recommended

// Specifies the title of the notification.
readwrite attribute string               title

// Specifies the URL of the icon to display.
readwrite attribute string               icon

/// Optional

// A unique ID for the notification. It can be used for duplicate detection.
// If this is not set, a unique ID will be generated.
readwrite attribute string               id

// Specifies the additional subtitle. For example, this could be used to
// display the appointment time for the calendar notification.
readwrite attribute string               subtitle

// Specifies the main content of the notification. For example, email 
// notifications could put snippet in this field.
readwrite attribute string               description

// This is the time when the notification is meant to be displayed. If this is
// not provided, the notification will be displayed immediately.
readwrite attribute Date                 displayAtTime

// This is the time when the notification is meant to go away. If this is not
// set, the notification just get displayed and goes away after the default
// timeout. If it is set, then once displayed, the notification will remain on
// screen until the user dismisses it or the desired time has arrived.
readwrite attribute Date                 displayUntilTime

// Adds an action for this notification.
// The parameter text specifies the text to display for the action.
// The parameter url either denotes the URL to launch in the browser that (first)
// sent the notification. If that browser is no longer running, then the
// default browser is launched. 
// If the url starts with "http://gears.google.com/notifier/actions", then
// it has a special behavior.
// Currently, the only defined special behavior is
// "http://gears.google.com/notifier/actions/snooze?duration=X", which means
// to snooze for X seconds.
void addAction(string text, string url)

Comment by lakatos.levente, Jul 14, 2008

Hi. I would use this API in my website. My question is if this is only a proposal implementation, or it is already included in the Gear package? I paste the example above in my file, and met the following error:

desktop.createNotification is not a function

Thanks for your help.

Comment by avatar21, Jul 18, 2008

Hi all,

Yeah, Notifier is not working ... what am I missing?

I'm preparing a POC solution to customer, please help.

Regards, Avatar Ng

Comment by avatar21, Jul 18, 2008

Think not release yet ... see the released features:

http://code.google.com/apis/gears/upcoming/history.html

notification = google.gears.factory.create("beta.notifier","1.0"); looking at the code above, do we have to wait until version 1.0?

any road map?

by Avatar Ng

Comment by psychcf1, Aug 14, 2008

You're missing an opening ' on this line: notification.title = Barbecue on Saturday';

Comment by 4umedia, Sep 05, 2008

When will this API be released?

Comment by drgath, Sep 05, 2008

Ohhh.... this was confusing. I spent an hour or so trying to get this to work before I realized it wasn't available yet. =(

Comment by hndanesh, Sep 30, 2008

Does anyone know when this is being released? I really need such thing in an application... any alternatives?

Comment by rklophaus, Oct 10, 2008

An alternative that may meet your needs is Stitcho. (http://stitcho.com)

It is a new notification platform that gives web applications the ability to display alerts and reminders on the desktop.

Comment by Thomaschaaf, Nov 05, 2008

I would really love this feature! Google Gears team should do polls to find out what the devs want.

Comment by electronixtar, Dec 10, 2008

赞一个。顶

Comment by chr.seiler, Dec 11, 2008

Any updates when this will be available?

Comment by mike.tovino, Dec 12, 2008

Yep, count this as another vote!

Comment by jadamt, Jan 22, 2009

I agree this would be awesome!

Comment by adrian.ziobro, Jan 30, 2009

Is it going to be integrated with Growl (which is de facto notification standard on Mac OS X) or Google is following Microsoft path with making somtehing "newer nad better"?

Comment by bluebroady, Feb 18, 2009

+1 for converting it to use Growl if available.

Comment by salmiak911, Feb 28, 2009

+1 for the style show on the pic abowe. This would be soo cool to run togheter with a wp runDetached scriöpt! Right now I'm thinking on my browserbased rpg. like if you gets attacked -> notification shown. when clicked the user gets a popupwindow (not browser, but a customstyled dialogue (background image), with only passwordinput) and then they are shown a page with actions that are relative.

Comment by eduardocereto, Mar 10, 2009

Gears should use the notification system for the underlying OS rather than creating a new one.

you should take a look at the awesome work being done on Ubuntu redesigning notifications concept: https://wiki.ubuntu.com/NotifyOSD

Comment by tom3oa, May 21, 2009

It seems like this forum is an attended. at least no body can reply when this amazing feature will actually be ready.

Does any body has an idea of when?

Comment by aj0020020, Jun 16, 2009

Does this code go in the head or body?

Comment by arivoli, Jul 05, 2009

Is this implemented in the new version.. ? i am not able to create notification object

Comment by jch92592, Oct 07, 2009

Status? Is the Notification API available?

Comment by alex.giers, Nov 16, 2009

Long time no news... anything or anyone knows something about this API?

Comment by rastrano, Dec 14, 2009

Any news on this topic...??? BrowserPlus? (http://browserplus.yahoo.com/developer/web/toolbox/notify/) of Yahoo implemented it (but not the onclick event on the notification popup that's the real important thing in my need (sending clickable links to webapp pages from server to the Desktop is very useful in event driven application development: eg. like monitoring tools, chats, etc.) I hope google team is working in this way... web need it!


Sign in to add a comment
Hosted by Google Code