Detect if Rich Notifications in Chrome are available

梦想的初衷 提交于 2019-12-05 04:55:15
Somas T

To detect if you have rich notifications, the most reliable way is currently to test for the existence of webkitNotifications.createHTMLNotification - if that function is undefined, then rich notifications have been switched on.

Just use this code:

if (webkitNotifications && webkitNotifications.createHTMLNotification) {
    //HTML notifications
} else if (chrome.notifications && chrome.notifications.create) {
    //Rich notifications
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!