From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/pt-br/web/api/notificationaction/index.html | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 files/pt-br/web/api/notificationaction/index.html (limited to 'files/pt-br/web/api/notificationaction/index.html') diff --git a/files/pt-br/web/api/notificationaction/index.html b/files/pt-br/web/api/notificationaction/index.html new file mode 100644 index 0000000000..a7cb904ac5 --- /dev/null +++ b/files/pt-br/web/api/notificationaction/index.html @@ -0,0 +1,79 @@ +--- +title: NotificationAction +slug: Web/API/NotificationAction +translation_of: Web/API/NotificationAction +--- +
{{APIRef("Web Notifications")}}{{AvailableInWorkers}}{{securecontext_header}}
+ +

A interface NotificationAction de Notifications API é usada para representar botões de ação que o usuário pode clicar para intergair com as notificações. As aparências e as funcionalidades específicas dos botões variam entre plataformas, mas geralmente providenciam maneiras de mostrar ações assincronamente ao usuário, em forma de notificações.

+ +

Propriedades

+ +

Propriedades de instância

+ +

Essas propriedades estão disponíveis somente para instâncias do objeto Notification.

+ +
+
{{domxref("NotificationAction.action")}} {{readonlyinline}}
+
O nome da ação, que pode ser usado para identificar a ação clicada, similiar a input names.
+
{{domxref("NotificationAction.title")}} {{readonlyinline}}
+
Uma string descrevendo a ação que sera mosrada ao usuário.
+
{{domxref("NotificationAction.icon")}} {{readonlyinline}}
+
O URL da imagem usado para representar a notificação quando não houver espaço suficiente para mostrar a propria notificação.
+
+ +

Exemplo

+ +

Notifications can fire {{Event("notificationclick")}} events on the {{domxref("ServiceWorkerGlobalScope")}}.

+ +

Here a service worker shows a notification with a single "Archive" action, allowing users to perform this common task from the notification without having to open the website. The user can also click the main body of the notification to open their inbox instead.

+ +
self.registration.showNotification("New mail from Alice", {
+  actions: [
+    {
+      action: 'archive',
+      title: 'Archive'
+    }
+  ]
+});
+
+self.addEventListener('notificationclick', function(event) {
+  event.notification.close();
+  if (event.action === 'archive') {
+    // Archive action was clicked
+    archiveEmail();
+  } else {
+    // Main body of notification was clicked
+    clients.openWindow('/inbox');
+  }
+}, false);
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Living standard
+ +

Browser compatibility

+ + + +

{{Compat("api.Notification")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf