It’s important for you being a blogger or a website owner that the viewer/reader sticks maximum period with your site; it’s such a crucial success judging factor. However, one can’t spend maximum time even if he wants if he/she is having minimal power available with his/her system. Well, you can now easily have information regarding the battery level of your visitor’s device (smart phone/laptop). You can do it through the help of Battery Status API.
It works nice along browsing options like Google Chrome, Opera and Firefox over the desktop. If you are an Android user, then you can enjoy it through Google Chrome.
Get Complete Detail of Charges with the Visitor’s Mobile
It can offer through above practice with the details like, whether the viewer’s device (smartphone/laptop) is presently on charge or not, the amount of charge remaining, or the amount it has been charged already. You can also get to know about the remaining period for the battery to get completely charged, or the time remaining in seconds for the battery to get absolutely discharged.
For Having Extended Information
You can link event listeners to ensure the battery data is upgraded; the moment the battery level of the device’s battery is changed, at the same time the visitor is present over your site. For a better result, you can be even smarter and add this along Google Analytics and get the battery charge information of device of the visitor through Events in Analytics.
That’s not the whole stuff; you can have further information as well. For example, when the power of the device of the viewer is getting lower, and it has been charged on or not; the coder can go with the option of saving the changes before the remaining battery is completely finished off.
The script is given below.
else if (navigator.battery)
console.log(“Sorry, Battery Status API is not supported”);
console.log(‘Charge level? ‘ + battery.level);
console.log(‘Battery charging? ‘ + battery.charging);
console.log(‘Time to charge? ‘ + battery.chargingTime);
console.log(‘Time to discarge? ‘ + battery.dischargingTime);
You can certainly expect up to the mark result following the above steps. Leave your precious comments below for further reference.