From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- files/es/web/api/notification/body/index.html | 63 +++ files/es/web/api/notification/dir/index.html | 59 +++ files/es/web/api/notification/icon/index.html | 58 +++ files/es/web/api/notification/index.html | 430 +++++++++++++++++++++ files/es/web/api/notification/onclick/index.html | 61 +++ .../es/web/api/notification/permission/index.html | 191 +++++++++ .../api/notification/requestpermission/index.html | 143 +++++++ 7 files changed, 1005 insertions(+) create mode 100644 files/es/web/api/notification/body/index.html create mode 100644 files/es/web/api/notification/dir/index.html create mode 100644 files/es/web/api/notification/icon/index.html create mode 100644 files/es/web/api/notification/index.html create mode 100644 files/es/web/api/notification/onclick/index.html create mode 100644 files/es/web/api/notification/permission/index.html create mode 100644 files/es/web/api/notification/requestpermission/index.html (limited to 'files/es/web/api/notification') diff --git a/files/es/web/api/notification/body/index.html b/files/es/web/api/notification/body/index.html new file mode 100644 index 0000000000..46c3209386 --- /dev/null +++ b/files/es/web/api/notification/body/index.html @@ -0,0 +1,63 @@ +--- +title: Notification.body +slug: Web/API/notification/body +tags: + - API + - API Notificaciones + - Javascript Notificador + - Notificaciones +translation_of: Web/API/Notification/body +--- +

{{APIRef("Web Notifications")}}

+ +

{{ SeeCompatTable() }}

+ +

Resumen 

+ +

El body es la  propiedad que representa el contenido  de la notificacion.

+ +

Los valores por esta propiedad son enviandos durante la  instanciación de {{domxref("Notification")}}  definiendo la propiedad body en el objeto de las opciones pasa al {{domxref("Notification")}} constructor.

+ +

Sintaxis

+ +
var body = instanceOfNotification.body;
+
+ +

Tipo

+ +

String.

+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + + + +
EspecificacionEstadoComentario
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Initial specification.
   
+ + + +

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+ +

Ver también

+ + diff --git a/files/es/web/api/notification/dir/index.html b/files/es/web/api/notification/dir/index.html new file mode 100644 index 0000000000..35f58dfca7 --- /dev/null +++ b/files/es/web/api/notification/dir/index.html @@ -0,0 +1,59 @@ +--- +title: Notification.dir +slug: Web/API/notification/dir +translation_of: Web/API/Notification/dir +--- +

{{APIRef("Web Notifications")}}

+ +

{{ SeeCompatTable() }}

+ +

Resumen

+ +

La propiedad dir indica la direccion para el lenguaje a usar dentro de la notificación.

+ +

El valor por esta propiedad es envianda durante la instanciancion de {{domxref("Notification")}} mediante la definición de la propiedad dir el objeto de las opciones pasa al {{domxref ("Notificación")}} constructor.

+ +

Sintaxis

+ +
var direction = instanceOfNotification.dir;
+
+ +

Tipo

+ +

String representa la actual direccion. puede ser:  

+ + + +

Especificaciones

+ + + + + + + + + + + + + + + + +
EspecificacionEstadoComentarios
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Initial specification.
+ + + +

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+ +

Ver tambien

+ + diff --git a/files/es/web/api/notification/icon/index.html b/files/es/web/api/notification/icon/index.html new file mode 100644 index 0000000000..deb7c0606e --- /dev/null +++ b/files/es/web/api/notification/icon/index.html @@ -0,0 +1,58 @@ +--- +title: Notification.icon +slug: Web/API/notification/icon +translation_of: Web/API/Notification/icon +--- +

{{APIRef("Web Notifications")}}

+ +

{{ SeeCompatTable() }}

+ +

Resumen

+ +

La propiedad icon indica la URL del icono a usar dentro de la notificacion.

+ +

El valor para esta propiedad es enviada durante la instanciacion {{domxref("Notification")}}  definiendo la propiedad icon el objeto pasa al  {{domxref("Notification")}} constructor.

+ +

Sintaxis

+ +
var icon = instanceOfNotification.icon;
+
+ +

Tipo

+ +

String que representa una URL válida.

+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + + + +
EspecificacionEstadoComentario
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Initial specification.
   
+ + + +

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+ +

Ver también

+ + diff --git a/files/es/web/api/notification/index.html b/files/es/web/api/notification/index.html new file mode 100644 index 0000000000..a673bc5739 --- /dev/null +++ b/files/es/web/api/notification/index.html @@ -0,0 +1,430 @@ +--- +title: Notification +slug: Web/API/notification +translation_of: Web/API/Notification +--- +
{{APIRef("Web Notifications")}}
+ +
+ +

La interfaz Notification de la Notifications API se usa para configurar y mostrar notificaciones de escritorio al usuario. La apariencia y las funcionalidad especificas de esta notificacion varia a traves de las distintas plataformas, pero generalmente esta plataformas proveen un camino para proveer informacion al usuario de manera asincronica.

+ +

{{AvailableInWorkers}}

+ +

Constructor

+ +
+
{{domxref("Notification.Notification", "Notification()")}}
+
Crea una nueva instancia del objecto Notification.
+
+ +

Propiedades

+ +

Propiedades Estáticas

+ +

Estas propiedades solo estan disponibles en el objecto Notification en sí mismo.

+ + + +
+
{{domxref("Notification.permission")}} {{readonlyinline}}
+
Una cadena que representa el permiso actual para mostrar notificaciones. Los valores posibles son:
+
+ + + + + +
+
+ +

Propiedades de Instancia

+ +

Estas propiedades solo están disponibles en instancias del objecto Notification.

+ +
+
{{domxref("Notification.actions")}} {{readonlyinline}}
+
Arreglo de acciones de la notificación, como se especifica en el parámetro de opciones del constructor.
+
{{domxref("Notification.badge")}} {{readonlyinline}}
+
URL de la imagen usada para representar la notificación cuando no hay espacio suficiente para mostrarla.
+
+ +
+
{{domxref("Notification.title")}} {{readonlyinline}}
+
El título de la notificación como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.dir")}} {{readonlyinline}}
+
La dirección del texto de la notificación como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.lang")}} {{readonlyinline}}
+
El código del lenguaje de la notificación como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.body")}} {{readonlyinline}}
+
The body string de la notificación como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.tag")}} {{readonlyinline}}
+
El ID de la notificación (si hay) como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.icon")}} {{readonlyinline}}
+
La URL de la imagen usada como ícono de la notificación como está especificado en el parámetro options del constructor.
+
{{domxref("Notification.image")}} {{readonlyinline}}
+
URL de una imagen para mostrar como parte de la notificación, al igual que se especifica en el parámetro de opciones del constructor.
+
{{domxref("Notification.data")}} {{readonlyinline}}
+
Retorna un clon estructurado de los datos de la notificación.
+
{{domxref("Notification.requireInteraction")}} {{readonlyinline}}
+
Un {{jsxref("Boolean")}} indicando en dispositivos pantallas lo suficientemente grandes, una notificación debería permanecer activa hasta que el usuario haga click o la descarte.
+
{{domxref("Notification.silent")}} {{readonlyinline}}
+
Especifica si la notificación debería ser silenciada, por ejemplo sin generar sonidos o vibraciones, independientemente de la configuración del dispositivo.
+
{{domxref("Notification.timestamp")}} {{readonlyinline}}
+
Especifica el tiempo en la cual una notificación fué creada o aplicable (pasado, presente o futuro).
+
{{domxref("Notification.vibrate")}} {{readonlyinline}}
+
Especifica un patrón de vibración para dispositivos que disponen de hardware para emitirlo. 
+
+ +

Propiedades no soportadas

+ +

Las siguientes propiedades están listadas en las especificaciones más actualizadas, pero aún no están soportadas por los navegadores. Es aconsejable verificarlas regularmente para ver si el estado de ellas ha sido actualizado, y háganos saber si encuentra información desactualizada.

+ +
+
{{domxref("Notification.noscreen")}} {{readonlyinline}}
+
Specifies whether the notification firing should enable the device's screen or not.
+
{{domxref("Notification.renotify")}} {{readonlyinline}}
+
Especifica si se debe notificar al usuario después de que una notificación nueva reemplace a una anterior.
+
{{domxref("Notification.sound")}} {{readonlyinline}}
+
Especifica un recurso de sonido para reproducir cuando se activa la notificación, en lugar del sonido de notificación del sistema predeterminado.
+
{{domxref("Notification.sticky")}} {{readonlyinline}}
+
+
Especifica si la notificación debe ser 'fija', es decir, no fácilmente eliminable por el usuario.
+
+
{{domxref("Notification.vibrate")}} {{readonlyinline}}
+
+
Especifica un patrón de vibración para los dispositivos con hardware de vibraciones para emitir.
+
+
+ +

Manejador de Eventos(Event Handler)

+ +
+
{{domxref("Notification.onclick")}}
+
Un manejador para el {{event("click")}} event. Sera inicializado cada vez que el usuario de click en la notificacion.
+
{{domxref("Notification.onerror")}}
+
A handler for the {{event("error")}} event. It is triggered each time the notification encounters an error.
+
+ +

Obsolete handlers

+ +

The following event handlers are still supported as listed in the {{anch("browser compatibility")}} section below, but are no longer listed in the current spec. It is safe therefore to assume they are obsolete, and may stop working in future browser versions.

+ +
+
{{domxref("Notification.onclose")}}
+
A handler for the {{event("close")}} event. It is triggered when the user closes the notification.
+
{{domxref("Notification.onshow")}}
+
A handler for the {{event("show")}} event. It is triggered when the notification is displayed.
+
+

Methods

+ +

Static methods

+ Estos métodos están disponibles solo en el objeto de Notificación en sí.
+
+
{{domxref("Notification.requestPermission()")}}
+
Solicita permiso del usuario para mostrar notificaciones.
+
+

Instance methods

+ +

These properties are available only on an instance of the Notification object or through its prototype. The Notification object also inherits from the {{domxref("EventTarget")}} interface.

+
+
{{domxref("Notification.close()")}}
+
Programmatically closes a notification.
+
+

Example

+ +

Assume this basic HTML:

+ +
<button onclick="notifyMe()">Notify me!</button>
+ +

It's possible to send a notification as follows — here we present a fairly verbose and complete set of code you could use if you wanted to first check whether notifications are supported, then check if permission has been granted for the current origin to send notifications, then request permission if required, before then sending a notification.

+ +
function notifyMe() {
+  // Let's check if the browser supports notifications
+  if (!("Notification" in window)) {
+    alert("This browser does not support desktop notification");
+  }
+
+  // Let's check whether notification permissions have already been granted
+  else if (Notification.permission === "granted") {
+    // If it's okay let's create a notification
+    var notification = new Notification("Hi there!");
+  }
+
+  // Otherwise, we need to ask the user for permission
+  else if (Notification.permission !== 'denied') {
+    Notification.requestPermission(function (permission) {
+      // If the user accepts, let's create a notification
+      if (permission === "granted") {
+        var notification = new Notification("Hi there!");
+      }
+    });
+  }
+
+  // At last, if the user has denied notifications, and you 
+  // want to be respectful there is no need to bother them any more.
+}
+ +

{{EmbedLiveSample('Example', '100%', 30)}}

+ +

In many cases, you don't need to be this verbose. For example, in our Emogotchi demo (see source code), we simply run {{domxref("Notification.requestPermission")}} regardless to make sure we can get permission to send notifications (this uses the newer promise-based method syntax):

+ +
Notification.requestPermission().then(function(result) {
+  console.log(result);
+});
+ +

Then we run a simple spawnNotification() function when we want to fire a notification — this is passed arguments to specify the body, icon and title we want, then it creates the necessary options object and fires the notification using the {{domxref("Notification.Notification","Notification()")}} constructor.

+ +
function spawnNotification(theBody,theIcon,theTitle) {
+  var options = {
+      body: theBody,
+      icon: theIcon
+  }
+  var n = new Notification(theTitle,options);
+}
+ +

Specifications

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

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5{{property_prefix("webkit")}}[1]
+ 22
4.0 {{property_prefix("moz")}}[2]
+ 22
{{CompatNo}}256[3]
icon5{{property_prefix("webkit")}}[1]
+ 22
4.0 {{property_prefix("moz")}}[2]
+ 22
{{CompatNo}}25{{CompatNo}}
Available in workers{{CompatVersionUnknown}}{{CompatGeckoDesktop("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
silent{{CompatChrome(43.0)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
noscreen, sticky{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
sound{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
renotify{{CompatChrome(50.0)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Promise-based Notification.requestPermission(){{CompatUnknown}}{{CompatGeckoDesktop("47.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}} +

{{CompatVersionUnknown}}

+
4.0{{property_prefix("moz")}}[2]
+ 22
1.0.1{{property_prefix("moz")}}[2]
+ 1.2
{{CompatNo}}{{CompatUnknown}}{{CompatNo}} +

{{CompatVersionUnknown}}

+
icon{{CompatUnknown}}{{CompatVersionUnknown}}4.0{{property_prefix("moz")}}[2]
+ 22
1.0.1{{property_prefix("moz")}}[2]
+ 1.2
{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatVersionUnknown}}
Available in workers{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
silent{{CompatNo}}{{CompatChrome(43.0)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatChrome(43.0)}}
noscreen, sticky{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
sound{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}
renotify{{CompatNo}}{{CompatChrome(50.0)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
Promise-based Notification.requestPermission(){{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("47.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] Before Chrome 22, the support for notification followed an old prefixed version of the specification and used the {{domxref("window.navigator.webkitNotifications","navigator.webkitNotifications")}} object to instantiate a new notification.

+ +

Before Chrome 32, {{domxref("Notification.permission")}} was not supported.

+ +

Before Chrome 42, service worker additions were not supported.

+ +

Starting in Chrome 49, notifications do not work in incognito mode.

+ +

[2] Prior to Firefox 22 (Firefox OS <1.2), the instantiation of a new notification must be done with the {{domxref("window.navigator.mozNotification", "navigator.mozNotification")}} object through its createNotification method.

+ +

Prior to Firefox 22 (Firefox OS <1.2), the Notification was displayed when calling the show method and supported only the click and close events.

+ +

Nick Desaulniers wrote a Notification shim to cover both newer and older implementations.

+ +

One particular Firefox OS issue is that you can pass a path to an icon to use in the notification, but if the app is packaged you cannot use a relative path like /my_icon.png. You also can't use window.location.origin + "/my_icon.png" because window.location.origin is null in packaged apps. The manifest origin field fixes this, but it is only available in Firefox OS 1.1+. A potential solution for supporting Firefox OS <1.1 is to pass an absolute URL to an externally hosted version of the icon. This is less than ideal as the notification is displayed immediately without the icon, then the icon is fetched, but it works on all versions of Firefox OS.

+ +

When using notifications  in a Firefox OS app, be sure to add the desktop-notification permission in your manifest file. Notifications can be used at any permission level, hosted or above: "permissions": { "desktop-notification": {} }

+ +

[3] Safari started to support notification with Safari 6, but only on Mac OSX 10.8+ (Mountain Lion).

+ +

See also

+ Using the Notifications API
+
diff --git a/files/es/web/api/notification/onclick/index.html b/files/es/web/api/notification/onclick/index.html new file mode 100644 index 0000000000..211947a1b8 --- /dev/null +++ b/files/es/web/api/notification/onclick/index.html @@ -0,0 +1,61 @@ +--- +title: Notification.onclick +slug: Web/API/notification/onclick +tags: + - API + - DOM + - Notifications + - Propiedad + - Referencia + - onclick +translation_of: Web/API/Notification/onclick +--- +

{{APIRef("Web Notifications")}}

+ +

La propiedad onclick de la interfaz {{domxref("Notification")}} especifica un event listener para recibir eventos {{event("click")}}. Estos eventos ocurren cuando el usuario hace un click sobre el {{domxref("Notification")}} mostrado.

+ +

Sintaxis

+ +
Notification.onclick = function(event) { ... };
+
+ +

El comportamiento por defecto es mover el foco al viewport del sitio de contexto de dicha notificación. Si no deseas este comportamiento, puedes llamar preventDefault() en el objeto del evento.

+ +

Ejemplos

+ +

En el siguiente ejemplo, utilizamos un manejador onclick para abrir un sitio web en una nueva pestaña (especificado con la inclusión del parámetro '_blank') una vez que la notifación es cliqueada.

+ +
notification.onclick = function(event) {
+  event.preventDefault(); // Previene al buscador de mover el foco a la pestaña del Notification
+  window.open('http://www.mozilla.org', '_blank');
+}
+ +

Especificaciones

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Web Notifications','#dom-notification-onclick','onclick')}}{{Spec2('Web Notifications')}}Living standard.
+ +

Compatibilidad de navegadores

+ +

{{Page("/en-US/docs/Web/API/Notification","Browser compatibility")}}

+ +

Mira también

+ + diff --git a/files/es/web/api/notification/permission/index.html b/files/es/web/api/notification/permission/index.html new file mode 100644 index 0000000000..d528e2f9e0 --- /dev/null +++ b/files/es/web/api/notification/permission/index.html @@ -0,0 +1,191 @@ +--- +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}}

+ +

Sintaxis

+ +
var permission = Notification.permission;
+ +

Valor

+ +

Una {{domxref("DOMString")}} que representa el permiso actual. El valor puede ser:

+ + + +

Ejemplos

+ +

Podríamos usar el próximo fragmento para:

+ +
    +
  1. Comprobar si las notificaciones están soportadas
  2. +
  3. Comprobar si el permiso ha sido concedido para el origen actual +
      +
    1. Si ha sido concedido, lanzar la notificación
    2. +
    3. Si no ha sido concedido, pedir el permiso
    4. +
    5. Si se concede, lanzar la notificación
    6. +
    +
  4. +
+ +
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.
+}
+ +

Especificaciones

+ + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName("Web Notifications","#dom-notification-permission","permission")}}{{Spec2('Web Notifications')}}Living standard
+ +

Compatibilidad en navegadores

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico5 {{ property_prefix("webkit") }} (see notes)
+ 22
{{CompatVersionUnknown}}4.0 {{ property_prefix("moz") }} (see notes)
+ 22
{{ CompatNo() }}256 (see notes)
Available in workers{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome 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}}
+
+ +

Notas de Firefox OS

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}

+ +

Notas de Chrome

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}

+ +

Notas de Safari

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}

+ +

Ver también

+ + diff --git a/files/es/web/api/notification/requestpermission/index.html b/files/es/web/api/notification/requestpermission/index.html new file mode 100644 index 0000000000..6c4b8080b3 --- /dev/null +++ b/files/es/web/api/notification/requestpermission/index.html @@ -0,0 +1,143 @@ +--- +title: Notification.requestPermission() +slug: Web/API/notification/requestPermission +translation_of: Web/API/Notification/requestPermission +--- +

{{APIRef("Web Notifications")}}

+ +

El método requestPermission() de la interfaz {{domxref("Notification")}} realiza una petición de permiso al usuario para que en ese dominio web se puedan mostrar notificaciones. 

+ +

Sintaxis

+ +

La ultima especificación ha actualizado este método a una sintaxis basada en Promise:

+ +
Notification.requestPermission().then(function(permission) { ... });
+ +

Anteriormente, la sintaxis se basaba en una simple retrollamada (callback); esta especificación ahora está obsoleta.

+ +
Notification.requestPermission(callback);
+ +

Parámetros

+ +
+
callback {{optional_inline}} {{deprecated_inline("gecko46")}}
+
Una retrollamada (callback) opcional que es ejecutado con el valor del permiso elegido por el usuario. Obsoleto y reemplazado por el valor de retorno de Promise.
+
+ +

Retorno

+ +

Devuleve un Promise que se transforma a DOMString con el permiso escogido por el usuario. Los valores posibles para este son granted, denied, ó default.

+ +

Ejemplo

+ +

El siguiente fragmento realiza la petición de permiso al usuario, después registra un resultado diferente dependiendo de la elección del usuario.

+ +
Notification.requestPermission(function(result) {
+  if (result === 'denied') {
+    console.log('Permission wasn\'t granted. Allow a retry.');
+    return;
+  } else if (result === 'default') {
+    console.log('The permission request was dismissed.');
+    return;
+  }
+  // Hacer algo con el permiso concedido.
+});
+ +

Especificaciones

+ + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('Web Notifications')}}{{Spec2('Web Notifications')}}Living standard
+ +

Compatibilidad con los buscadores

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico5 {{ property_prefix("webkit") }} (ver notas)
+ 22
4.0 {{ property_prefix("moz") }} (ver notas)
+ 22
{{ CompatNo() }}256 (ver notas)
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Soporte básico{{ CompatUnknown() }} +

{{CompatVersionUnknown}}

+
4.0 {{ property_prefix("moz") }} (ver notas)
+ 22
1.0.1 {{ property_prefix("moz") }} (ver notas)
+ 1.2
{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatNo() }} +

{{CompatVersionUnknown}}

+
+
+ +

Notas de Firefox OS

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}

+ +

Notas de Chrome

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}

+ +

Notas de Safari

+ +

{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}

+ +

Ver también

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