I'm making a Chrome extension that receives Chrome Google Cloud Messages. I want to detect when computer wakes up from sleep/reconnects to internet, so that my application can start receiving messages again. For my specific case, I don't want GCM to throttle the pushes, so I set the ttl to 0, which is deliver now or never. (user device will never receive message while idle.)
In javascript, how do I detect when Chrome browser recovers from idle state?
More specifically, how could I do it in Chrome extension using chrome. api calls?
Chrome has an idle 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With