show orange Windows taskbar icon orange when a Chr

2019-09-02 05:40发布

问题:

I am working on a Chrome Packaged App that sends notifications (which are now all hooked up). However, when the user is not in the app -- the app is in the background with other windows on top of it -- the notification pops up for a bit and disappears. I would like to change the taskbar icon to orange, the same that the Hangouts packaged app does, so that the user knows there is a notification to view at a later time.

I looked all though the notifications documentation and could not find any such feature, yet Hangouts is using it, and I believe I have seen it in other apps. Does anyone know how to trigger this in a Chrome Packaged App?

Thanks.

回答1:

It looks like I have figured it out, and it only took all day. This behavior is not part of notifications (that would be too easy), but rather of the app window. So, you would do something like this:

var appWindow = chrome.app.window.current();
appWindow.drawAttention();

This flashes the taskbar icon orange in Windows, and makes the dock icon bounce in OSX.

You can also call appWindow.clearAttention(), although attention would be cleared automatically when the user focuses the window.