Firefox Tomorrow

web api instance property

NotificationEvent: action property

View on MDN ↗

Available in workers

The action read-only property of the NotificationEvent interface returns the string ID of the notification button the user clicked. This value returns an empty string if the user clicked the notification somewhere other than an action button, or the notification does not have a button. The notification id is set during the creation of the Notification via the actions array attribute and can’t be modified unless the notification is replaced.

Value

A string.

Examples

self.registration.showNotification("New articles available", {
  actions: [{ action: "get", title: "Get now." }],
});

self.addEventListener("notificationclick", (event) => {
  event.notification.close();
  if (event.action === "get") {
    synchronizeReader();
  } else {
    clients.openWindow("/reader");
  }
});

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.