Chrome desktop notification example [closed]

2018-12-31 14:30发布

How does one use Chrome desktop notifications? I'd like that use that in my own code.

Update: Here's a blog post explaining webkit notifications with an example.

9条回答
浮光初槿花落
2楼-- · 2018-12-31 15:20

For some reason the accepted answer didn't work for me, I ended up using the following example:

https://developer.chrome.com/apps/app_codelab_alarms#create-notification

function notifyMe() {

    chrome.notifications.create('reminder', {
        type: 'basic',
        iconUrl: 'icon.png',
        title: 'Don\'t forget!',
        message: 'You have  things to do. Wake up, dude!'
    }, function(notificationId) {});

}
查看更多
泪湿衣
3楼-- · 2018-12-31 15:23

Check the design and API specification (it's still a draft) or check the source from (page no longer available) for a simple example: It's mainly a call to window.webkitNotifications.createNotification.

If you want a more robust example (you're trying to create your own Google Chrome's extension, and would like to know how to deal with permissions, local storage and such), check out Gmail Notifier Extension: download the crx file instead of installing it, unzip it and read its source code.

查看更多
浅入江南
4楼-- · 2018-12-31 15:24

Here is nice documentation on APIs,

https://developer.chrome.com/apps/notifications

And, official video explanation by Google,

https://developers.google.com/live/shows/83992232-1001

查看更多
登录 后发表回答