Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Extension Notifications API: Templates, Permissions and Events

How browser extensions declare the notifications permission, call create(), choose template types, and handle platform limits on macOS and ChromeOS.

This page summarises Chrome’s extension documentation on the browser.notifications API (also exposed as chrome.notifications in older samples). The API lets an extension post rich, templated messages to the user’s system tray (notification center), not only inside the browser window.

Use the chrome.notifications API to create rich notifications using templates and show these notifications to users in the system tray.

— Chrome, notifications API reference

Extensions can also reach users through the web platform Notifications API; this article focuses on the extensions Notifications API described in Notify users and Use the Notifications API.

notifications permission: manifest declaration before create()

Section titled “notifications permission: manifest declaration before create()”

You must declare the notifications permission in manifest.json before calling notifications.create(). Without it, the extension cannot show system notifications.

Post messages to a user’s system tray using the extensions Notifications API. Start by declaring the “notifications” permission in the manifest.json.

— Chrome, Notify users

A minimal permission block looks like this:

{
"permissions": [
"notifications"
]
}

The same pattern appears in the alarms codelab, which combines alarms, storage, and notifications. Legacy Manifest V2 samples that used webkitNotifications also required notifications and sometimes web_accessible_resources for icon paths (desktop notifications); current extensions should use browser.notifications instead of deprecated WebKit APIs.

notifications.create(): ID, options, and replacement behavior

Section titled “notifications.create(): ID, options, and replacement behavior”

notifications.create() creates and displays one notification. In current reference material it returns a Promise<string> with the notification ID:

Creates and displays a notification.

— Chrome, notifications API reference

Signature (MV3-style):

await browser.notifications.create(notificationId, options);

Parameters from the API reference:

Parameter Role
notificationId (optional string) Stable ID for updates. If omitted or empty, Chrome generates one. If it matches an existing notification, that notification is cleared first, then recreated. Max length 500 characters. Required before Chrome 42 in older docs.
options NotificationOptions: template type, text, icons, buttons, priority, etc.

Manifest V2 examples sometimes use a callback instead of a Promise (MV2 reference).

To use this API, call the notifications.create() method, passing in the notification details via the options parameter

— Chrome, Rich notifications API (MV2 article)

For notifications.create(), the reference marks these as required in practice:

  • type: a TemplateType ("basic", "image", "list", or "progress").
  • iconUrl: small icon beside the message (data URL, blob URL, or URL relative to a resource in the extension package).
  • title and message: primary heading and body text.

The notifications.NotificationOptions must include a notifications.TemplateType, which defines available notification details and how those details are displayed.

— Chrome, Use the Notifications API

Template types: basic, image, list, and progress

Section titled “Template types: basic, image, list, and progress”

Rich notifications use four template flavors. All include a title, message, small left icon, and optional contextMessage (lighter third line of text).

Rich notifications come in four different flavors: basic, image, list, and progress.

— Chrome, Use the Notifications API

type What the user sees Extra option fields
"basic" Icon, title, message, up to two buttons —
"image" Above plus image preview imageUrl
"list" Icon, title, message, list items, buttons items[] with per-item title and message
"progress" Progress bar (0–100) progress

Enum wording from the API reference:

“basic” — Contains an icon, title, message, expandedMessage, and up to two buttons.

“image” — Contains an icon, title, message, expandedMessage, image, and up to two buttons.

“list” — Contains an icon, title, message, items, and up to two buttons. Users on Mac OS X only see the first item.

“progress” — Contains an icon, title, message, progress, and up to two buttons.

From Notify users (hydration reminder):

browser.alarms.onAlarm.addListener(() => {
browser.action.setBadgeText({ text: '' });
browser.notifications.create({
type: 'basic',
iconUrl: 'stay_hydrated.png',
title: 'Time to Hydrate',
message: "Everyday I'm Guzzlin'!",
buttons: [{ title: 'Keep it Flowing.' }],
priority: 0
});
});

List, image, and progress templates follow the same required fields; see the template sections in Use the Notifications API.

Priority, buttons, silent, and requireInteraction

Section titled “Priority, buttons, silent, and requireInteraction”

Optional NotificationOptions fields control behavior and chrome around the message:

Field Behavior
priority -2 to 2 (default 0). On platforms without a notification center (Windows, Linux, Mac as described in the reference), -2 and -1 error because those notifications are never shown. On ChromeOS, priorities < 0 go to the notification center; > 0 stay visible longer and allow more high-priority items in the tray (how they behave).
buttons Up to two action buttons (NotificationButton[]). Clicks fire notifications.onButtonClicked.
requireInteraction If true, notification stays until the user activates or dismisses it (default false).
silent If true, no sound or vibration when shown (default false).
progress 0–100 for type: "progress".
eventTime Timestamp in ms since epoch.

Deprecated or ignored fields in the reference include appIconMaskUrl, imageUrl visibility on old Mac builds, and isClickable (ignored since Chrome 67). Prefer current API reference over MV2-only articles marked deprecated.

macOS and ChromeOS: native UI vs system tray rules

Section titled “macOS and ChromeOS: native UI vs system tray rules”

Notifications look and behave differently by platform. This matters when you test list, image, and progress templates.

Note: Notifications appear differently for Mac OS X users. Instead of Chrome’s own notifications, users see Mac OS X notifications.

— Chrome, Use the Notifications API

Practical differences documented across Use the Notifications API and Rich notifications API:

Feature macOS (Chrome 59+) Other notes
Image preview imageUrl not shown Use type: "basic" if image preview is essential on Mac.
List items Only the first item visible Do not rely on multi-line lists on Mac.
Progress UI Percentage in the title, not a bar Set title text accordingly for Mac users.
Priority ordering No effect on order ChromeOS uses priority for center vs tray duration.
ChromeOS tray Notifications stay until dismissed; tray counts new items until opened Documented in how they behave.

onButtonClicked: responding to action buttons

Section titled “onButtonClicked: responding to action buttons”

All template types may include up to two buttons. Register a listener on browser.notifications.onButtonClicked (see browser.events):

browser.notifications.onButtonClicked.addListener((notificationId, buttonIndex) => {
// Respond to the action matching buttons[buttonIndex]
});

MV2 samples used chrome.notifications.onButtonClicked with the same pattern (Rich notifications API). Keep handlers in the service worker so clicks work when no UI page is open.

Common mistakes when using extension notifications

Section titled “Common mistakes when using extension notifications”
  1. Calling create() without "notifications" in the manifest — permission must be declared first (Notify users).
  2. Omitting iconUrl, title, message, or type — all are required for a valid rich notification (API reference).
  3. Using priority: -1 or -2 on Windows, Linux, or Mac — the API errors because those levels are not shown without a notification center.
  4. Expecting full list or image layouts on macOS — only first list item and no image preview on current Mac behavior.
  5. Using deprecated webkitNotifications or HTML notifications — replaced by template-based browser.notifications (desktop notifications).
  6. Wrong image type — image previews need type: "image" and imageUrl, not type: "basic" with only imageUrl (Use the Notifications API).

MV2 extension articles (richNotifications) note that the Chrome Web Store no longer accepts Manifest V2; migrate to Manifest V3 and the Promise-based browser.* namespace in the current reference.

  1. Add "notifications" to permissions in manifest.json, matching Notify users.
  2. Load the extension unpacked in Chrome and open Extensions → your extension → Errors to catch permission or priority failures.
  3. Trigger browser.notifications.create() with type: "basic", iconUrl, title, and message; confirm the banner appears in the OS notification area.
  4. On macOS, repeat with type: "list", "image", and "progress" and compare behavior to Use the Notifications API platform notes.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.