From 314c4f6dc27fe96925a8dee20b8296baeff2c141 Mon Sep 17 00:00:00 2001 From: Anderson Vallejo <48649209+Vallejoanderson@users.noreply.github.com> Date: Mon, 7 Feb 2022 19:08:54 -0500 Subject: Content sync and updated to md | Notification.permission [ES] (#4033) * Content sync and updated to md * Apply suggestions from code review Co-authored-by: David Brito <39559632+davbrito@users.noreply.github.com> Co-authored-by: David Brito <39559632+davbrito@users.noreply.github.com> --- .../es/web/api/notification/permission/index.html | 191 --------------------- files/es/web/api/notification/permission/index.md | 77 +++++++++ 2 files changed, 77 insertions(+), 191 deletions(-) delete mode 100644 files/es/web/api/notification/permission/index.html create mode 100644 files/es/web/api/notification/permission/index.md (limited to 'files') diff --git a/files/es/web/api/notification/permission/index.html b/files/es/web/api/notification/permission/index.html deleted file mode 100644 index d528e2f9e0..0000000000 --- a/files/es/web/api/notification/permission/index.html +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: Notification.permission -slug: Web/API/notification/permission -translation_of: Web/API/Notification/permission ---- -
{{APIRef("Web Notifications")}}
- -La propiedad permission
es una propiedad de sólo lectura de la interfaz {{domxref("Notification")}}. Esta propiedad indica el permiso concedido por el usuario para mostrar notificaciones.
{{AvailableInWorkers}}
- -var permission = Notification.permission;- -
Una {{domxref("DOMString")}} que representa el permiso actual. El valor puede ser:
- -granted
: El usuario ha concedido el permiso explicitamente al origen actual para mostrar notificaciones del sistema.denied
: El usuario ha denegado el permiso explicitamente al origen actual para mostrar notificaciones del sistema.default
: La decisión del usuario es deconocida; en este caso la aplicación actuará como si el permiso fuese denied
Podríamos usar el próximo fragmento para:
- -function notifyMe() { - // Comprobamos si el navegador soporta las notificaciones - if (!("Notification" in window)) { - console.log("Este navegador no es compatible con las notificaciones de escritorio"); - } - - // Comprobamos si los permisos han sido concedidos anteriormente - else if (Notification.permission === "granted") { - // Si es correcto, lanzamos una notificación - var notification = new Notification("Hola!"); - } - - // Si no, pedimos permiso para la notificación - else if (Notification.permission !== 'denied' || Notification.permission === "default") { - Notification.requestPermission(function (permission) { - // Si el usuario nos lo concede, creamos la notificación - if (permission === "granted") { - var notification = new Notification("Hola!"); - } - }); - } - - // Por último, si el usuario ha denegado el permiso, y quieres ser respetuoso, no hay necesidad de molestarlo. -}- -
Especificación | -Estado | -Comentario | -
---|---|---|
{{SpecName("Web Notifications","#dom-notification-permission","permission")}} | -{{Spec2('Web Notifications')}} | -Living standard | -
{{ CompatibilityTable() }}
- -Característica | -Chrome | -Edge | -Firefox (Gecko) | -Internet Explorer | -Opera | -Safari | -
---|---|---|---|---|---|---|
Soporte básico | -5 {{ property_prefix("webkit") }} (see notes) - 22 |
- {{CompatVersionUnknown}} | -4.0 {{ property_prefix("moz") }} (see notes) - 22 |
- {{ CompatNo() }} | -25 | -6 (see notes) | -
Available in workers | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatGeckoDesktop("41.0")}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -
Característica | -Android | -Android Webview | -Edge | -Firefox Mobile (Gecko) | -Firefox OS | -IE Mobile | -Opera Mobile | -Safari Mobile | -Chrome for Android | -
---|---|---|---|---|---|---|---|---|---|
Soporte básico | -{{ CompatUnknown() }} | -
- {{CompatVersionUnknown}} - |
- {{CompatVersionUnknown}} | -4.0 {{ property_prefix("moz") }} (see notes) - 22 |
- 1.0.1 {{ property_prefix("moz") }} (see notes) - 1.2 |
- {{ CompatNo() }} | -{{ CompatUnknown() }} | -{{ CompatNo() }} | -
- {{CompatVersionUnknown}} - |
-
Available in workers | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatGeckoMobile(41.0)}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -{{CompatUnknown}} | -
{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}
- -{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}
- -{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}
- -