3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】Notification API

Posted at
if(window.Notification != null) {
  // Notificationを許可するかどうかを問い合わせる
  Notification.requestPermission(function(permission){
    // 許可されなかったら何もしない
    if(permission !== "granted"){
      return;
    }
    
    // タイトルと本文、アイコンを表示
    var options = {};
    options.icon = '';
    options.body = 'HogePiyoFooBar';
    new Notification('Title', options);  // instance作っても何もできなくない?
  });
}

ChromeでもFirefoxでも動作自体はしてびっくり。
意外と簡単に実装できるようになってるんですね、Notification API。

しかしなんでinstance作るんだろう…。
何か使うことになるのかな。

3
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?