In this instance, the Nativescript Plugin is utilized.
let power = require("nativescript-powerinfo");
power.startPowerUpdates(function (Info) {
console.log("battery charge: " + Info.percent + "%");
});
The output in the console would be: battery charge: 100 %
The goal here is to store the value of Info.percent into a variable for future use.
Unfortunately, every attempt to do so results in it being undefined. Various methods were experimented with:
var batterystatus = power.startPowerUpdates(function(Info){
return Info.percent;
}
or
power.startPowerUpdates(function(Info){
return Info.percent;
var batterystatus = power.startPowerUpdates(function);
and also:
var batterystatus = power.startPowerUpdates(function(Info){
this.batterystatus = Info.percent
}
However, none of these approaches yielded the correct result.
The type of Info.percent is identified as a number.