[41] Web における Notifications API は、著者から利用者に対する通知のための
API です。 Notification
オブジェクトは通知を表します。
showNotification
#✎[38] 2008年5月、 OS が通知の仕組みを提供するのが一般的になってきていたことや Google Gears >>36
や Opera Widgets >>32, >>33 のように Web にもこれを持ち込む動きが出てきたことを受け >>34、
HTML5 に showNotification
API が追加されました >>28。
この API は平文の通知に対応していました。
[39] しかし Google Gears は平文ではなく HTML による通知を望んでいたこと、
他の Webブラウザーが実装の意思を示さなかったことから、 showNotification
は削除されました >>31, >>27。 Ian Hickson は、 HTML の通知はプラットフォーム側の通知
API と統合できなくなることを指摘し、複数の実装者が興味を示さない限り (Ian により)
仕様に含めることを拒んでいます >>37。それに対し Mike Smith は W3C
での標準化を提案しており、これが Web Notifications WG へとつながったようです。
[64] W3C は Web Notification Working Group を設立し、 Web Notifications 仕様の開発を始めました。
[59] annevk が W3C から締め出されたため、 Web Notifications は WHATWG に移り、 Notifications API Standard >>14 となりました。
[60] annevk が Chair 兼編集者だった W3C Web Notifications WG は閉鎖されるかに見えましたが >>16、 Apple の Jon Lee が Chair を引き受けたため >>17、継続されることになりました。
[61] 以後 W3C 側は WHATWG の (一部の) 変更をコピペして Web Notifications 仕様書を出版しています。
[62] WHATWG ではその後も実装経験と需要を踏まえた改訂が進められています。
新機能としては音声やバイブレーション、 Service Worker
との統合が規定されています。 show
や close
のような不要とされたイベントは削除されています。
[63] W3C はこうした WHATWG での改訂が進められる前の、 annevk 時代とほぼ同じ古い版を W3C Process に従い W3C勧告へと進めようとしています。 Mozilla や Google は実態に合わない仕様書を出版することに反対しました >>57, >>55 が、 W3C Director である TimBL は注意書きを添えれば十分 >>54 と主張して CR へと進めています >>58。
[66] W3C の仕様書には「前編集者」と「WHATWG 編集者」しかいない奇妙な状態 >>58 ですが、 ED >>65 の履歴によると実際の作業は Edward O'Connor が行っているようです。
[69] 1052776 – Desktop notifications not accessible: Not read by screen reader, and fade away ( 版) https://bugzilla.mozilla.org/show_bug.cgi?id=1052776
[70] PSA: Android is *only* shipping Service Worker-based Notifications - Google Groups ( 版) https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/BygptYClroM
[71] Issue 901843006: Allow the embedder to disable the Notification constructor. - Code Review ( 版) https://codereview.chromium.org/901843006
[72] Web Notifications ( ( 版)) http://www.w3.org/TR/2015/PR-notifications-20150910/
[73] Web Notifications ( 版) http://www.w3.org/TR/2015/REC-notifications-20151022/
new Notification('Hello', {body: 'Yay!'});
This was never supported on Android due to restrictions of the platform: specifically, Chrome can’t support the callbacks on the Notification object, such as onclick. But it’s used on desktop for displaying notifications for web apps you may currently have open.
The best way to feature detect for Android and desktop at the moment is to do the following:
function isNewNotificationSupported() {
if (!window.Notification || !Notification.requestPermission)
return false;
if (Notification.permission == 'granted')
throw new Error('You must only call this \*before\* calling
Notification.requestPermission(), otherwise this feature detect would bug the
user with an actual notification!');
try {
new Notification();
} catch (e) {
if (e.name == 'TypeError')
return false;
}
return true;
}
[76] Fix #50: clarify the impact of using the "renotify" flag · whatwg/notifications@a25f64f ( 版) https://github.com/whatwg/notifications/commit/a25f64fee4b2c11034c490a8130d50123a9b87be
[77] Web Notifications in Microsoft Edge | Microsoft Edge Dev Blog ( ()) https://blogs.windows.com/msedgedev/2016/05/16/web-notifications-microsoft-edge/
[78] CodeIQ MAGAZINE|エンジニアのためのWebマガジン () https://codeiq.jp/magazine/
[79] >>78 アクセスすると (開いただけで) 通知の承認を要求されます。
出初めたぐらいに「これ、どうでもいい個人サイトとかもやりだしたらうざいだろうな」と思っていたけど、最近まさにそういう状態になっている。当然サービスワーカーもインストールされてる。ほとんどの場合サイトにアクセスしたときに勝手に出る。
[91] 朝日新聞デジタル:朝日新聞社のニュースサイト () https://www.asahi.com/
[92] >>91 アクセスすると (開いただけで) 通知の承認を要求されます。
[81] Add image property to notifications (johnmellor著, ) https://github.com/whatwg/notifications/commit/8ccf1ac50444818ab013f43cb228f728e15ad126
[82] Use current global object for ServiceWorkerGlobalScope check (annevk著, ) https://github.com/whatwg/notifications/commit/434ccaf63410f5fe71e7dd75a69bb9dee953079b
[83] Resolve showNotification() after showing notification (jakearchibald著, ) https://github.com/whatwg/notifications/commit/bc5b3596625024e1b30704a244b3bd27ecbf5786
[84] Meta: update spec deploy and editing infrastructure (annevk著, ) https://github.com/whatwg/notifications/commit/6ecf5958c0f46ed635c1cbe05e65bd47c08caac5
[85] Meta: enable PR preview and link web-platform-tests (annevk著, ) https://github.com/whatwg/notifications/commit/8f54686682e33435ec0a1d3c7fcee6a028ba842e
[86] Use title variable correctly in create a notification (annevk著, ) https://github.com/whatwg/notifications/commit/62c4d283a38f5e996b92ef7dfd230aa6ab61c38e
[87] Moving to the the Native Notification System on Mac OS X | Web | Google Developers () https://developers.google.com/web/updates/2017/04/native-mac-os-notifications
You can feature detect image support with the following code:
if ('image' in Notification.prototype) {
// Image is supported.
} else {
// Image is NOT supported.
}
[89] 516147 - [Feature Request] Display Chrome notifications in Action Center on Windows 10 - chromium - Monorail () https://bugs.chromium.org/p/chromium/issues/detail?id=516147
[90] Use StructuredSerializeForStorage (annevk著, ) https://github.com/whatwg/notifications/commit/8323d18ede1f7cfddd34b4260dd8408b16807ddd
[93] Require user gesture to request notification permissions · Issue #49 · WICG/interventions () https://github.com/WICG/interventions/issues/49
[94] Deprecations and Removals in Chrome 61 | Web | Google Developers () https://developers.google.com/web/updates/2017/08/chrome-61-deprecations
[95] Meta: use new WHATWG boilerplate and license (domenic著, ) https://github.com/whatwg/notifications/commit/2dacbc8c4991bbc88ca67c64d443782c9dbfcb37
[96] Meta: use new WHATWG boilerplate and license by domenic · Pull Request #118 · whatwg/notifications () https://github.com/whatwg/notifications/pull/118
[97] Add show and close events back (annevk著, ) https://github.com/whatwg/notifications/commit/19616183fb52717d59313dd23bfa9e649081ce74
[98] Remove support for sounds from notifications (beverloo著, ) https://github.com/whatwg/notifications/commit/459bf358cae197a5b88c6a227e018756ef4c21cd
[99] Remove support for sounds from notifications by beverloo · Pull Request #127 · whatwg/notifications () https://github.com/whatwg/notifications/pull/127
[100] Merge replacing and displaying into showing (annevk著, ) https://github.com/whatwg/notifications/commit/e9407ebcc7f6606d5cc5fe2f6e1d6bb92e9158cd
[101] Merge replacing and displaying into showing by annevk · Pull Request #126 · whatwg/notifications () https://github.com/whatwg/notifications/pull/126
[102] Review Draft Publication: July 2018 (annevk著, ) https://github.com/whatwg/notifications/commit/1733e392f38a7beea07f45aedbfaeb6fce410080
[103] Review Draft Publication: July 2018 by annevk · Pull Request #137 · whatwg/notifications () https://github.com/whatwg/notifications/pull/137
[104] Notifications API Standard Review Draft July 2018 () https://notifications.spec.whatwg.org/review-drafts/2018-07/
[105] Memorandum of Understanding Between W3C and WHATWG () https://www.w3.org/2019/04/WHATWG-W3C-MOU.html
[106] Remove obsolete replace steps reference (annevk著, ) https://github.com/whatwg/notifications/commit/31c625a90c61f6b0c580dd8f84a28faa93390626
[107] Remove obsolete replace steps reference by annevk · Pull Request #141 · whatwg/notifications () https://github.com/whatwg/notifications/pull/141
[108] Review Draft Publication: January 2019 (annevk著, ) https://github.com/whatwg/notifications/commit/4a053333020d52bd898f2a3cc2c6e1830bf00eff
[109] Review Draft Publication: January 2019 by annevk · Pull Request #143 · whatwg/notifications () https://github.com/whatwg/notifications/pull/143
[110] Notifications API Standard Review Draft January 2019 () https://notifications.spec.whatwg.org/review-drafts/2019-01/
[112] Chrome + Windows で表示されないことがある、なんでだろう。 DevTools では表示されたことになっているのに、実際には何も出てこないし Windows の通知一覧にも入っていない。
[113] Align with IDL constructor changes (autokagami著, ) https://github.com/whatwg/notifications/commit/976813ca068627405c972318441622ad94ff7557
[114] [notifications] Align with Web IDL specification by autokagami · Pull Request #151 · whatwg/notifications () https://github.com/whatwg/notifications/pull/151
[115] Fighting notification spam in Microsoft Edge - Microsoft Edge Blog, Microsoft Edge Blog, https://blogs.windows.com/msedgedev/2023/07/06/fighting-notification-spam-microsoft-edge/