3 This API is currently available on ChromeOS, Windows, and Mac.
6 <h2 id=
"usage">Usage
</h2>
10 call the $ref:notifications.create method,
11 passing in the notification details
12 via the
<code>options
</code> parameter:
16 chrome.notifications.create(id, options, creationCallback);
20 The $ref:notifications.NotificationOptions must include a
21 $ref:notifications.TemplateType,
22 which defines available notification details
23 and how those details are displayed.
28 (
<code>basic
</code>,
<code>image
</code>, and
<code>list
</code>)
29 must include a notification
<code>title
</code> and
<code>message
</code>,
30 as well as an
<code>iconUrl
</code>, which is a link to a small icon that
31 is displayed to the left of the notification message. The
<code>image
</code>
32 template type also includes an
<code>imageUrl
</code>, which is a link to
33 an image that is previewed within the notification.
34 Due to a strict
<a href=
"contentSecurityPolicy.html">Content Security Policy
</a>
35 in Chrome Apps, these URLs must point to a local resource or use a
36 <a href=
"app_external.html">data URL
</a>.
40 Here's an example of a
<code>basic
</code> template:
46 title:
"Primary Title",
47 message:
"Primary message to display",
48 iconUrl:
"url_to_small_icon"
53 The
<code>list
</code> template displays
<code>items
</code>
60 title:
"Primary Title",
61 message:
"Primary message to display",
62 iconUrl:
"url_to_small_icon",
63 items: [{ title:
"Item1", message:
"This is item 1."},
64 { title:
"Item2", message:
"This is item 2."},
65 { title:
"Item3", message:
"This is item 3."}]
70 Let us know if you have ideas for new templates with varying layouts
71 by filing a
<a href=
"http://crbug.com/new">crbug
</a>!
74 <h2 id=
"events">Listening for and responding to events
</h2>
77 All notifications can include event listeners and event handlers
78 that respond to user actions.
80 you can write an event handler to respond to an
81 $ref:notifications.onButtonClicked event.
84 <p>Consider including event listeners and handlers within the
85 <a href=
"app_lifecycle.html#create_event_page">event page
</a>,
86 so that notifications can pop-up even when the app or extension isn't running.