Chrome is detected when a computer wakes up from a standby state

I am making a Chrome extension that receives Google Chrome cloud messages. I want to detect when a computer wakes up from sleep / connects to the Internet, so that my application can start receiving messages again. In my specific case, I don't want GCM to throttle the click, so I set ttl to 0, which is being delivered now or never. (The user device will never receive a message while idle.)

In javascript, how to detect when the Chrome browser is recovering from the idle state?

More specifically, how could I do this in a Chrome extension using chrome. api calls?

+4
source share
1 answer

Chrome has a simple API:

chrome.idle.onStateChanged(function(state) {
    if (state == 'active') {
        console.log('State is now active');
    }
});

You can read about it here: https://developer.chrome.com/apps/idle

+5
source

All Articles