From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- files/de/web/api/notification/index.html | 265 +++++++++++++++++++++ .../de/web/api/notification/permission/index.html | 187 +++++++++++++++ 2 files changed, 452 insertions(+) create mode 100644 files/de/web/api/notification/index.html create mode 100644 files/de/web/api/notification/permission/index.html (limited to 'files/de/web/api/notification') diff --git a/files/de/web/api/notification/index.html b/files/de/web/api/notification/index.html new file mode 100644 index 0000000000..aaf5188c37 --- /dev/null +++ b/files/de/web/api/notification/index.html @@ -0,0 +1,265 @@ +--- +title: Notification +slug: Web/API/notification +translation_of: Web/API/Notification +--- +
{{APIRef("Web Notifications")}} {{ SeeCompatTable() }}
+ +
Das Notification interface wird zum konfigurieren und Anzeigen von desktop notifications verwendet.
+ +

Permissions

+ +

Wenn Sie notifications in einer offenen web app verwenden, fügen sie die desktop-notification permission zu ihrem manifest file hinzu. Notifications können für jedes permission level, hosted oder darüber verwendet werden.

+ +
"permissions": {
+    "desktop-notification":{}
+}
+ +

Konstruktor

+ +
var notification = new Notification(title, options);
+ +

Parameter

+ +
+
title
+
Titel der innerhalb der Notification angezeigt werden muss.
+
options {{optional_inline}}
+
Ein Objekt das optionale Konfigurationsparamter enthält. Es kann die folgenden Einträge enthalten: +
    +
  • dir : Die Ausrichtung des Textes; Verfügbar sind auto, ltr, oder rtl.
  • +
  • lang:  Spezifiziere die verwendete Sprache. Dieser String muss ein valides BCP 47 language tag sein.
  • +
  • body:  Ein String, welcher jeglichen extra Inhalt einer notification beinhaltet.
  • +
  • tag: Die ID einer gegebene notification, um diese abzurufen, zu löschen, zu ersetzen oder zu löschen. 
  • +
  • icon: Die Url für das verwendete Icon in einer notification.
  • +
  • data: Ein Benutzerdefiniertes Datenfeld.
  • +
+
+
+ +

Properties

+ +

Static properties

+ +

Diese Eigenschaften sind nur im Notification-Objekt selbst verfügbar.

+ +
+
{{domxref("Notification.permission")}} {{readonlyinline}}
+
Eine Zeichenkette, die die aktuell gesetzten Berechtigungen Notifications anzuzeigen darstellt. Mögliche Werte sind: denied (der Nutzer erlaubt keine Benachrichtigungen), granted (der Nutzer akzeptiert, dass Benachrichtigungen angezeigt werden) oder default (die Nutzerwahl ist unbekannt, daher verhält sich der Browser wie bei denied).
+
+ +

Instance properties

+ +

Diese Eigenschaften sind nur in Instanzen des Notification-Objekts verfügbar.

+ +
+
{{domxref("Notification.title")}} {{readonlyinline}}
+
Der Titel der Benachrichtigung der in den Parametern des Konstruktors spezifiziert wurde.
+
{{domxref("Notification.dir")}} {{readonlyinline}}
+
Textausrichtung der Benachrichtung welche in den Parametern des Konstruktors spezifiziert wurde.
+
{{domxref("Notification.lang")}} {{readonlyinline}}
+
Sprachcode der Benachrichtung welche in den Parametern des Konstruktors spezifiziert wurde.
+
{{domxref("Notification.body")}} {{readonlyinline}}
+
Textinhalt der Benachrichtung welche in den Parametern des Konstruktors spezifiziert wurde.
+
{{domxref("Notification.tag")}} {{readonlyinline}}
+
ID der Benachrichtung (if any) welche in den Parametern des Konstruktors spezifiziert wurde.
+
{{domxref("Notification.icon")}} {{readonlyinline}}
+
URL des Bildes welches als Icon der Benachrichtgung verwendet wird, wie in den Parametern des Konstruktors spezifiziert wurde
+
{{domxref("Notification.data")}} {{readonlyinline}}
+
Returns a structured clone of the notification’s data.
+
+ +

Event handlers

+ +
+
{{domxref("Notification.onclick")}}
+
A handler for the {{event("click")}} event. It is triggered each time the user clicks on the notification.
+
{{domxref("Notification.onshow")}}
+
A handler for the {{event("show")}} event. It is triggered when the notification is displayed.
+
{{domxref("Notification.onerror")}}
+
A handler for the {{event("error")}} event. It is triggered each time the notification encounters an error.
+
{{domxref("Notification.onclose")}}
+
A handler for the {{event("close")}} event. It is triggered when the user closes the notification.
+
+ +

Methods

+ +

Static methods

+ +

These methods are available only on the Notification object itself.

+ +
+
{{domxref("Notification.requestPermission()")}}
+
Requests permission from the user to display notifications. This method must be called as the result of a user action (for example, an onclick event), and cannot be used without it.
+
+ +

Instance methods

+ +

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

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

{{page("/en-US/docs/Web/API/EventTarget","Methods")}}

+ +

Example

+ +

Assume this basic HTML:

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

It's possible to send a notification as follows:

+ +
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 alredy 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.
+}
+ +

See the live result

+ +

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

+ +

Specifications

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

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5 {{ property_prefix("webkit") }} (see notes)
+ 22
4.0 {{ property_prefix("moz") }} (see notes)
+ 22
{{ CompatNo() }}256 (see notes)
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Mobile
Basic support{{ CompatUnknown() }} +

{{CompatVersionUnknown}}

+
4.0 {{ property_prefix("moz") }} (see notes)
+ 22
1.0.1 {{ property_prefix("moz") }} (see notes)
+ 1.2
{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatNo() }} +

{{CompatVersionUnknown}}

+
+
+ +

Gecko notes

+ + + +

Chrome notes

+ + + +

Android notes

+ + + +

Safari notes

+ + + +

Notes

+ +

{{ref("1")}} Deprecated since Android 4.0.

+ +

See also

+ + diff --git a/files/de/web/api/notification/permission/index.html b/files/de/web/api/notification/permission/index.html new file mode 100644 index 0000000000..bd381fe34c --- /dev/null +++ b/files/de/web/api/notification/permission/index.html @@ -0,0 +1,187 @@ +--- +title: Notification.permission +slug: Web/API/notification/permission +tags: + - API + - DOM + - Notifications + - Property + - Reference +translation_of: Web/API/Notification/permission +--- +

{{APIRef("Web Notifications")}}

+ +

Die schreibgeschützte Berechtigungseigenschaft der Schnittstelle {{domxref ("Notificaton")}} gibt die aktuelle Berechtigung an, die der Benutzer für den aktuellen Ursprung zur Anzeige von Web-Benachrichtigungen erteilt hat.

+ +

{{AvailableInWorkers}}

+ +

Syntax

+ +
var permission = Notification.permission;
+ +

Value

+ +

Ein {{domxref ("DOMString")}} repräsentiert die aktuelle Berechtigung. Der Wert kann sein:

+ + + +

Beispiele

+ +

Das folgende ziemlich ausführliche Snippet könnte verwendet werden, wenn Sie zuerst überprüfen möchten, ob Benachrichtigungen unterstützt werden, und prüfen Sie dann, ob für den aktuellen Ursprung die Erlaubnis für das Senden von Benachrichtigungen gewährt wurde, und fordern Sie dann bei Bedarf eine Genehmigung an, bevor Sie eine Benachrichtigung senden.

+ +
function notifyMe() {
+  // Let's check if the browser supports notifications
+  if (!("Notification" in window)) {
+    console.log("This browser does not support desktop notification");
+  }
+
+  // Let's check whether notification permissions have alredy 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.permission === "default") {
+    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.
+}
+ +

Spezifikationen

+ + + + + + + + + + + + + + +
SpezifikationStatusKommentar
{{SpecName("Web Notifications","#dom-notification-permission","permission")}}{{Spec2('Web Notifications')}}Lebensstandard
+ +

Browserkombatibilität

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Grundlegende Unterstützung5 {{ property_prefix("webkit") }} (see notes)
+ 22
{{CompatVersionUnknown}}4.0 {{ property_prefix("moz") }} (see notes)
+ 22
{{ CompatNo() }}256 (see notes)
Vorhanden in den Arbeitskräften{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
+

Grundlegende Unterstützung

+
{{ 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}}

+
Vorhanden in den Arbeitskräften{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(41.0)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Firefox OS Notizen

+ +

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

+ +

Chrome Notizen

+ +

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

+ +

Safari Notizen

+ +

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

+ +

Siehe auch

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