Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web/API/ServiceWorkerGlobalScope/notificationclick_event を更新 #23698

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
title: "ServiceWorkerGlobalScope: notificationclick イベント"
short-title: notificationclick
slug: Web/API/ServiceWorkerGlobalScope/notificationclick_event
l10n:
sourceCommit: e0e09b1df51489867f2e74c18586d168ba5e00d1
sourceCommit: 28848ba41c082db2a8c55e85c804bd06363afb57
---

{{APIRef}}
{{APIRef("Web Notifications")}}{{SecureContext_Header}}{{AvailableInWorkers("service")}}

**`notificationclick`** イベントは、 {{domxref("ServiceWorkerRegistration.showNotification()")}} によって生み出されたシステム通知がクリックされたことを示すために発生します。
**`notificationclick`** は {{domxref("ServiceWorkerGlobalScope")}} インターフェイスのイベントで、 {{domxref("ServiceWorkerRegistration.showNotification()")}} によって生み出されたシステム通知がクリックされたことを示すために発生します。

メインスレッドまたは {{domxref("Notification.Notification","Notification()")}} コンストラクターを使用するサービスワーカーではないワーカーで作成された通知は、{{domxref("Notification/click_event", "click")}} イベントを代わりに {{domxref("Notification")}} オブジェクト自体で受け取ります。

このイベントはキャンセル不可で、バブリングしません。

Expand All @@ -23,13 +26,13 @@ onnotificationclick = (event) => {};

## イベント型

{{domxref("NotificationEvent")}} です。 {{domxref("Event")}} を継承しています。
{{domxref("NotificationEvent")}} です。{{domxref("ExtendableEvent")}} および {{domxref("Event")}} を継承しています。

{{InheritanceDiagram("NotificationEvent")}}

## イベントプロパティ

_親である {{domxref("Event")}} からプロパティを継承しています_。
_祖先である {{domxref("ExtendableEvent")}} および {{domxref("Event")}} からプロパティを継承しています_。

- {{domxref("NotificationEvent.notification")}} {{ReadOnlyInline}}
- : クリックされイベントが発行された通知を表す {{domxref("Notification")}} オブジェクトを返します。
Expand Down Expand Up @@ -86,11 +89,11 @@ self.onnotificationclick = (event) => {
};
```

イベントのアクションは `event.action` を使って {{domxref("ServiceWorkerGlobalScope.notificationclick_event", "notificationclick")}} イベントハンドラーの中で処理することができます。
イベントのアクションは `event.action` を使って `notificationclick` イベントハンドラーの中で処理することができます。

```js
navigator.serviceWorker.register("sw.js");
Notification.requestPermission((result) => {
Notification.requestPermission().then((result) => {
if (result === "granted") {
navigator.serviceWorker.ready.then((registration) => {
// Archive というタイトルのアクションを含んだ通知を表示します。
Expand Down