+ 2
Why it eeror's??
4 Answers
+ 1
The battery property has been removed in favor of the standard Navigator.getBattery() method, which returns a battery Promise. Its support is still partial though.
Given that, you can run the code like this:
navigator.getBattery().then(function(battery){
alert('Battery: ' + battery.level * 100 + '%');
if(battery.charging) {
alert('Battery Status: Charging');
} else {
alert('Battery Status: Power cable not connected.');
}
});
Hope this helps.
0
it helps me but I want to write it without ".then"
0
See my code again I changed it but it shows battery level Nan
0
Can you write it without .then ??