0
Vaadinにhtml5ブラウザの「デスクトップ通知」はありますか?私はこれを探し、特定のものを見つけることができません。Vaadinのデスクトップ通知
私は運が無ければこのようなものを試しました。あなたは古いAPIを使用してみましたvaadin 8
Vaadinにhtml5ブラウザの「デスクトップ通知」はありますか?私はこれを探し、特定のものを見つけることができません。Vaadinのデスクトップ通知
私は運が無ければこのようなものを試しました。あなたは古いAPIを使用してみましたvaadin 8
を使用して
JavaScript.getCurrent().execute(
"if (window.webkitNotifications) {" +
"if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED" +
" window.webkitNotifications.createNotification(" +
" 'icon.png', 'Notification Title', 'Notification content...');" +
" } else {\n" +
" window.webkitNotifications.requestPermission();" +
" } " +
"} else { " +
" console.log('no notifications')" +
"}");
、それは多くのバージョンではサポートされていません。 new apiは動作するはずです:
JavaScript.getCurrent().execute(
" if (!(\"Notification\" in window)) { " +
" alert(\"This browser does not support system notifications\"); " +
" } else if (Notification.permission === \"granted\") { " +
" new Notification(\"Hi there!\"); " +
" } else if (Notification.permission !== 'denied') { " +
" Notification.requestPermission(function (permission) { " +
" if (permission === \"granted\") { " +
" Notification(\"Hi there!\"); " +
" } " +
" }); " +
" } "
);
これは良い方法です。
vaadin 7のプラグインがあります。https://vaadin.com/directory#!addon/webnotificationsにすることもできます。または、JavaScript componentを作成するか、少なくともJavaScript functionを作成すると簡単になります。