aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/api/notification/requestpermission/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/es/web/api/notification/requestpermission/index.html')
-rw-r--r--files/es/web/api/notification/requestpermission/index.html143
1 files changed, 143 insertions, 0 deletions
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
+---
+<p>{{APIRef("Web Notifications")}}</p>
+
+<p>El método <strong><code>requestPermission()</code></strong> de la interfaz {{domxref("Notification")}} realiza una petición de permiso al usuario para que en ese <a href="https://es.wikipedia.org/wiki/Dominio_de_Internet">dominio web</a> se puedan mostrar notificaciones. </p>
+
+<h2 id="Sintaxis">Sintaxis</h2>
+
+<p>La ultima especificación ha actualizado este método a una sintaxis basada en <code><a href="/es/docs/Web/JavaScript/Referencia/Objetos_globales/Promise">Promise</a></code>:</p>
+
+<pre class="brush: js">Notification.requestPermission().then(function(permission) { ... });</pre>
+
+<p>Anteriormente, la sintaxis se basaba en una simple retrollamada (callback); esta especificación ahora está obsoleta.</p>
+
+<pre class="brush: js">Notification.requestPermission(<em>callback</em>);</pre>
+
+<h3 id="Parámetros">Parámetros</h3>
+
+<dl>
+ <dt><code>callback</code> {{optional_inline}} {{deprecated_inline("gecko46")}}</dt>
+ <dd>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 <code><a href="/es/docs/Web/JavaScript/Referencia/Objetos_globales/Promise">Promise</a></code>.</dd>
+</dl>
+
+<h3 id="Retorno">Retorno</h3>
+
+<p>Devuleve un <code><a href="/es/docs/Web/JavaScript/Referencia/Objetos_globales/Promise">Promise</a></code> que se transforma a <code><a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMString">DOMString</a></code> con el permiso escogido por el usuario. Los valores posibles para este son <code>granted</code>, <code>denied</code>, ó <code>default</code>.</p>
+
+<h2 id="Ejemplo">Ejemplo</h2>
+
+<p>El siguiente fragmento realiza la petición de permiso al usuario, después registra un resultado diferente dependiendo de la elección del usuario.</p>
+
+<pre class="brush: js">Notification.requestPermission(<span class="s1">function</span>(result) {
+ <span class="s1">if</span> (result === <span class="s2">'denied'</span>) {
+<span class="s3"> console.log(</span>'Permission wasn\'t granted. Allow a retry.'<span class="s3">);</span>
+ <span class="s1">return</span>;
+ } else if (result === 'default') {
+  console.log('The permission request was dismissed.');
+  return;
+  }
+ // Hacer algo con el permiso concedido.
+});</pre>
+
+<h2 id="Especificaciones">Especificaciones</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificación</th>
+ <th scope="col">Estado</th>
+ <th scope="col">Comentario</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Web Notifications')}}</td>
+ <td>{{Spec2('Web Notifications')}}</td>
+ <td>Living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilidad_con_los_buscadores">Compatibilidad con los buscadores</h2>
+
+<p>{{ CompatibilityTable() }}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Soporte básico</td>
+ <td>5 {{ property_prefix("webkit") }} (ver notas)<br>
+ 22</td>
+ <td>4.0 {{ property_prefix("moz") }} (ver notas)<br>
+ 22</td>
+ <td>{{ CompatNo() }}</td>
+ <td>25</td>
+ <td>6 (ver notas)</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Soporte básico</td>
+ <td>{{ CompatUnknown() }}</td>
+ <td>
+ <p>{{CompatVersionUnknown}}</p>
+ </td>
+ <td>4.0 {{ property_prefix("moz") }} (ver notas)<br>
+ 22</td>
+ <td>1.0.1 {{ property_prefix("moz") }} (ver notas)<br>
+ 1.2</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatUnknown() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>
+ <p>{{CompatVersionUnknown}}</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h3 id="Notas_de_Firefox_OS">Notas de Firefox OS</h3>
+
+<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p>
+
+<h3 id="Notas_de_Chrome">Notas de Chrome</h3>
+
+<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p>
+
+<h3 id="Notas_de_Safari">Notas de Safari</h3>
+
+<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p>
+
+<h2 id="Ver_también">Ver también</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API">Usando la API de notificaciones</a></li>
+</ul>