traccar / traccar-client-ios

Traccar Client for iOS
https://www.traccar.org/client
Apache License 2.0
204 stars 304 forks source link

iOS Battery Level always 0 #31

Closed bradleyuk closed 7 years ago

bradleyuk commented 8 years ago

Hi

Not sure if this a defect or future proofed but the latest iOS client always seems to send batt=0 at the end of the query string.

Is this a placeholder for when battery level is supported or is this a defect?

Also quick question - if i increase the interval will it save battery? or is the GPS always on (and therefore draining) and just transmits at the interval provided?

Thanks

And great app btw!

tananaev commented 8 years ago

Looks like I need to set batteryMonitoringEnabled property to YES to be able to read battery status.

StasDoskalenko commented 8 years ago

Simple solution is:

-(double) batteryLevel
{
    UIDevice *myDevice = [UIDevice currentDevice];
    [myDevice setBatteryMonitoringEnabled:YES];
    double batteryLeft = (float)[myDevice batteryLevel] * 100;
    return batteryLeft;
}
tananaev commented 8 years ago

I will try to include in the next release.

StasDoskalenko commented 8 years ago

I did like it in my branch. Work fine but mistake near +/- 5-10%

w32gold commented 7 years ago

Hi, used the latest Traccar-iOS codes but still getting the "zero battery". Any further ideas in fixing this? thanks.

tananaev commented 7 years ago

It means that your device doesn't provide this information.

w32gold commented 7 years ago

Sorry for my ignorance, but how do I make the iPhone/iPad provide such battery information. I've seen it sending a battery percentage before. Thanks!

tananaev commented 7 years ago

The issue should be fixed now. We need to wait a bit till Apple approves the new version.