我的Chrome擴展程序大量使用webkitNotifications。我想切換到new rich notifications (chrome.notifications),但那些目前尚未在所有平臺上提供,並且只能在測試版頻道和更高版本中編寫。如果豐富的通知不可用,則應使用webkitNotifications作爲回退。因此,我在尋找實現這一目標的最佳解決方案:檢測Chrome中的Rich通知是否可用
if(richNotificationsAvailable())
chrome.notifications.create(...);
else
webkitNotifications.createNotification(...).show();
我試圖檢查chrome.notifications.create
未定義的,但它甚至爲Chrome 27在chrome://flags
禁用豐富的通知定義。
那豈不是更有意義的檢查此相反?要檢查它們是否已打開,不是沒有其他功能不可用? –
謝謝,檢查'webkitNotifications.createHTMLNotification' for undefined'工程!我已在Linux上的Chromium 29(dev)上確認了它,但Rich Notifications尚未提供:'createHTMLNotification'仍然定義。在Windows上,它從Chrome 28(測試版)開始未定義。 – user2425107