Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-31-2011, 11:58 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 1
kapil403 is on a distinguished road
Default 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!

Last edited by kapil403; 12-31-2011 at 12:12 PM. Reason: layout
kapil403 is offline   Reply With Quote
Old 12-31-2011, 01:20 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by kapil403 View Post
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:


Quote:
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

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 01-11-2012, 01:05 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Lahore, Pakistan
Posts: 26
saqibjaan is on a distinguished road
Send a message via Skype™ to saqibjaan
Default

You have to use startCalendarInterval in your plist file. This will help you update location after a specified period of time.
saqibjaan is offline   Reply With Quote
Old 01-11-2012, 02:35 AM   #4 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
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.
sneaky is offline   Reply With Quote
Reply

Bookmarks

Tags
battery, battery life, gps accelerometer, ios 5, iphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 397
13 members and 384 guests
7twenty7, AppsBlogger, comicool, Creativ, Dalia, dansparrow, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:53 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0