-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS Battery Level Issue with react-native-device-info
(-1 Value) until BackgroundGeolocation.start()
#1922
Comments
You dont need another plug-in to get the battery level. Background Geolocation provides the battery-level to each recorded location. |
We use this library not only for battery api, but in our case we need user battery level outside of user location context. |
When When |
This is a global property of the OS. |
Will this be a good solution for you to implement so you do not reset this global property ? class Geolocation {
private bool canChangeBatteryMonitoringProperty = false
public function start(){
if (! batteryMonitoringEnabled){
batteryMonitoringEnabled = true
canChangeBatteryMonitoringProperty = true
}
}
public function stop(){
...
if (canChangeBatteryMonitoringProperty){
batteryMonitoringEnabled = false
canChangeBatteryMonitoringProperty = false
}
...
}
} |
@christocracy is the above proposal a good solution for you to implement ? |
@christocracy Hi, did you manage to think about this ? We still need this |
This issue is stale because it has been open for 30 days with no activity. |
Up |
This issue is stale because it has been open for 30 days with no activity. |
Up |
Your Environment
react-native -v
): 0.72.4Expected Behavior
Actual Behavior
We use
react-native-device-info
plugin, version10.8.0
. We need to get battery level so we use https://github.com/react-native-device-info/react-native-device-info?tab=readme-ov-file#getbatterylevel api, but it returns -1. In their documentation its says to add this[UIDevice currentDevice].batteryMonitoringEnabled = true;
to AppDelegate, but i still get -1 level on a real device. But i found that as soon as i callBackgroundGeolocation.start()
, thegetBatteryLevel
returns the real device battery level and I dont get theBattery monitoring is not enabled. You need to enable monitoring with [UIDevice currentDevice].batteryMonitoringEnabled = TRUE
warningSteps to Reproduce
react-native-device-info
on an real iOS device. Also installreact-native-background-geolocation
.react-native-device-info
Context
The text was updated successfully, but these errors were encountered: