diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/notificationevent | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/fr/web/api/notificationevent')
-rw-r--r-- | files/fr/web/api/notificationevent/index.html | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/files/fr/web/api/notificationevent/index.html b/files/fr/web/api/notificationevent/index.html new file mode 100644 index 0000000000..12d31e9481 --- /dev/null +++ b/files/fr/web/api/notificationevent/index.html @@ -0,0 +1,162 @@ +--- +title: NotificationEvent +slug: Web/API/NotificationEvent +tags: + - API + - Experimental + - Interface + - Reference + - ServiceWorker +translation_of: Web/API/NotificationEvent +--- +<div>{{APIRef("Service Workers API")}}{{SeeCompatTable}}</div> + +<p>L'interface <strong><code>NotificationEvent</code></strong> représente un évènement de clic pour une notification et qui est dispatché vers le {{domxref("ServiceWorkerGlobalScope")}} d'un {{domxref("ServiceWorker")}}.</p> + +<p>Cette interface hérite de l'interface {{domxref("ExtendableEvent")}}.</p> + +<h2 id="Constructeur">Constructeur</h2> + +<dl> + <dt>{{domxref("NotificationEvent.NotificationEvent()")}}</dt> + <dd>Cette méthode permet de créer un nouvel objet <code>NotificationEvent</code>.</dd> +</dl> + +<h2 id="Propriétés">Propriétés</h2> + +<p><em>Cet objet hérite de propriétés grâce à son ancêtre : {{domxref("Event")}}</em>.</p> + +<dl> + <dt>{{domxref("NotificationEvent.notification")}} {{readonlyInline}}</dt> + <dd>Cette propriété renvoie un objet {{domxref("Notification")}} représentant la notification sur laquelle on a cliqué pour déclencher l'évènement.</dd> + <dt>{{domxref("NotificationEvent.action")}} {{readonlyinline}}</dt> + <dd>Cette propriété renvoie une chaîne de caractères identifiant le bouton de la notification sur lequel l'utilisateur a cliqué. Cette valeur sera {{jsxref("undefined")}} si l'utilisateur a cliqué autre part que sur le bouton pour la notification ou si la notification ne possède pas de bouton.</dd> +</dl> + +<h2 id="Méthodes">Méthodes</h2> + +<p><em>Cet objet hérite de méthodes grâce à son parent </em><em>{{domxref("ExtendableEvent")}}</em>.</p> + +<dl> + <dt>{{domxref("ExtendableEvent.waitUntil", "ExtendableEvent.waitUntil()")}}</dt> + <dd> + <p>Cette méthode allonge la durée de vie de l'évènement. Elle est conçue pour être appelée dans le gestionnaire d'évènement {{event("install")}} lors de l'installation (cf. {{domxref("ServiceWorkerRegistration.installing")}}) du <em>worker</em> et dans le gestionnaire d'évènement {{event("active")}} pour le <em>worker</em> actif (cf. {{domxref("ServiceWorkerRegistration.active")}}).</p> + </dd> +</dl> + +<h2 id="Exemples">Exemples</h2> + +<pre class="brush: js">self.addEventListener('notificationclick', function(event) { + console.log('Au clic sur la notification : ', event.notification.tag); + event.notification.close(); + + // On regarde ici si elle est déjà ouverte + // et si le focus est dessus + event.waitUntil(clients.matchAll({ + type: "window" + }).then(function(clientList) { + for (var i = 0; i < clientList.length; i++) { + var client = clientList[i]; + if (client.url == '/' && 'focus' in client) + return client.focus(); + } + if (clients.openWindow) + return clients.openWindow('/'); + })); +}); +</pre> + +<h2 id="Spécifications">Spécifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Spécification</th> + <th scope="col">État</th> + <th scope="col">Commentaires</th> + </tr> + <tr> + <td>{{SpecName('Web Notifications','#notificationevent','NotificationEvent')}}</td> + <td>{{Spec2('Web Notifications')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<div class="note"> +<p><strong>Note :</strong> Cette interface est définie au sein de <a href="/fr/docs/Web/API/Notifications_API">l'API Notifications</a>, mais on y accède via {{domxref("ServiceWorkerGlobalScope")}}.</p> +</div> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Fonctionnalité</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Support simple</td> + <td>{{CompatChrome(42)}}</td> + <td>{{CompatGeckoDesktop("44.0")}}<sup>[1]</sup></td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>action</code></td> + <td>{{CompatChrome(48)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Fonctionnalité</th> + <th>Android</th> + <th>Webview Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome pour Android</th> + </tr> + <tr> + <td>Support simple</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatGeckoMobile("44.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatChrome(42)}}</td> + </tr> + <tr> + <td><code>action</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatChrome(48)}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] Les <em>service workers</em> (ainsi que l'API <a href="/fr/docs/Web/API/Push_API">Push</a>) ont été désactivés dans l'édition <a href="https://www.mozilla.org/fr/firefox/organizations/">Firefox 45 Extended Support Release</a> (ESR).</p> |