Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Mobile Only in Gecko 2.0
Available only in Firefox Mobile as of Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Deprecated since Gecko 22 (Firefox 22 / Thunderbird 22 / SeaMonkey 2.19)
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Provides support for creating notification objects, which are used to display desktop notification alerts to the user. Currently, these are only supported on Firefox Mobile and Firefox OS. See Displaying notifications for an example.

The support for this property as been dropped in favor of the standard Notification constructor.

Method overview

notification createNotification(in DOMString title, in DOMString description, in DOMString iconURL Optional);

Methods

createNotification()

Creates and returns a notification object that can be used to display the specified message with an optional URL.

notification createNotification(
  in DOMString title,
  in DOMString description,
  in DOMString iconURL Optional
);
Parameters
title
The notification title.
description
The text to display in the notification.
iconURL Optional
A URL identifying the image to display in the notification.
Return value

A new notification object.

Permissions

When using notifications  in an open web app, be sure to add the desktop-notification permission in your manifest file:

"permissions": {
    "desktop-notification":{}
}

Usage notes

  • In Firefox 22+ (Firefox OS 1.1+), the instantiation of a new notification should be done with the Notification object by calling new Notification(title,options).
  • Nick Desaulniers has written a Notification shim to cover both newer and older implementations.
  • One particular Firefox OS issue is that you can pass a path to an icon to use in the notification, but if the app is packaged you cannot use a relative path like /my_icon.png. You also can't use navigator.location.origin + "/my_icon.png" because navigator.location.origin is null in packaged apps. The manifest origin field fixes this, but it is only available in Firefox OS 1.1+. A potential solution for supporting Firefox OS <1.1 is to pass an absolute URL to an externally hosted version of the icon. This is less than ideal as the notification is displayed immediately with the icon missing, then the icon is fetched, but it works on all versions of Firefox OS.

See also

Document Tags and Contributors

 Last updated by: teoli,