What should I use instead of navigator.getBattery(), as it is not working?
I am working on a chrome extension and with this what I want to do is –
function toggleBatterySaver(enable) {
if (enable) {
navigator.getBattery().then(battery => {
if (battery.level < 0.2) {
chrome.power.requestKeepAwake("system");
}
});
} else {
chrome.power.releaseKeepAwake();
}
}
It is throwing an error:
navigator.getBattery() is not a function.