Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

iPhone GPS - Battery Draining Extremely Fast ** Please Help **

Hi Gurus,

We are developing an app that has heavy GPS usage and we are unable to optimize the battery life. Even when the device is not moved, there is significant battery drainage which according to the code should not happen.

Here is the code:
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = 100;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];

We want to trigger GPS every 20 minutes (if there is no location change then save battery) OR every 5 minutes if there is location change. According to my developer this cannot be done.

Previously we were using kCLLocationAccuracyBest, which was consuming battery very fast and now we are using kCLLocationAccuracyHundredMeters.

startUpdatingLocation - is to get the GPS coordinates. There is another call startMonitoringSignificantLocationChanges which is to get AGPS coordinates which I believe returns the coordinates whenever cell tower will change, and hence consumes battery really fast.

distanceFilter - The minimum distance (measured in meters) a device must move laterally before an update event is generated. On the basis of distance filter we get the GPS fix from the device and then we send the updated GPS coordinates to the server.

Any help will be greatly appreciated Thank you!
Post edited by kapil403 on

Replies

  • Duncan CDuncan C Posts: 8,025Tutorial Authors, Registered Users
    kapil403;398293 said:
    Hi Gurus,

    We are developing an app that has heavy GPS usage and we are unable to optimize the battery life. Even when the device is not moved, there is significant battery drainage which according to the code should not happen.

    Here is the code:
    locationManager = [[CLLocationManager alloc] init];
    locationManager.distanceFilter = 100;
    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    [locationManager startUpdatingLocation];

    We want to trigger GPS every 20 minutes (if there is no location change then save battery) OR every 5 minutes if there is location change. According to my developer this cannot be done.

    Previously we were using kCLLocationAccuracyBest, which was consuming battery very fast and now we are using kCLLocationAccuracyHundredMeters.

    startUpdatingLocation - is to get the GPS coordinates. There is another call startMonitoringSignificantLocationChanges which is to get AGPS coordinates which I believe returns the coordinates whenever cell tower will change, and hence consumes battery really fast.

    distanceFilter - The minimum distance (measured in meters) a device must move laterally before an update event is generated. On the basis of distance filter we get the GPS fix from the device and then we send the updated GPS coordinates to the server.

    Any help will be greatly appreciated Thank you!
    If you leave the GPS actively updating your location, you will suck down the battery rapidly. Using a lower accuracy helps a little bit, but only a little bit.

    What we did for some of our development was to ask for location updates at regular intervals. We start updating the location, wait for a signal that has a current timestamp and acceptable accuracy, and then stop updating again for a period. The longer the interval while you are NOT updating locations, the better your battery life. It takes the GPS a fairly long time to get accurate readings after you start updating again though (15 to 30 seconds) so your update interval needs to be pretty long in order to get a good benefit from it.

    We haven't used it, but supposedly the significant location changes option is an excellent way to be notified of user movements with very low power use.

    To quote Apple's docs:
    This method indicates whether the device is able to report updates based on significant location changes only. (Significant location change monitoring primarily involves detecting changes in the cell tower currently associated with the device.) This capability provides tremendous power savings for applications that want to track a user’s approximate location and do not need highly accurate position information.
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
  • saqibjaansaqibjaan Posts: 31Registered Users
    You have to use startCalendarInterval in your plist file. This will help you update location after a specified period of time.
  • sneakysneaky Posts: 349Registered Users
    Duncan C;398303 said:

    We haven't used it, but supposedly the significant location changes option is an excellent way to be notified of user movements with very low power use.
    I used significant location changes in the last app I did. It does provide a low power option but the updates are not particularly reliable (in terms of frequency, not actual position.). If you want to use region coding it only works for iPhone 4/4s _Hardware_ - it's not only a feature of the OS but also of the hardware.

    If you are Ok with just getting a position every now and then then it's a good deal - but you will only get a position when you have traveled a significant distance. Depending on where you are testing this it could be several kilometers between updates.
Sign In or Register to comment.