iPhone Significant Location Change Battery Drain? - iphone

Question: Does the Significant Location Change background service drain battery easily? I'm trying to track longitude latitude readings when the there is a Significant Location Change. However, before starting, I just want to make sure that this doesn't drain the battery.
If the Location service described above does not drain battery, can someone recommend a way to store the location changes that would be battery efficient. My initial thought was to store the longitude latitude points locally on iPhone and then send the information to the server on a much less frequent basis (2 hours). Anyone have a better approach?
I'm trying to build a simple location tracking app that is battery efficient. Thanks all.

Significant location changes do not take any extra battery draining because the device uses information that the GSM system is working with anyway. It has to keep track of signal strength readings of multiple cell towers all the time anyway. Your app is only started/woken when certain criteria are met.
To conserve battery you have to watch two subsystems:
make sure that CoreLocation is turned off when you don't need it, GPS takes the most
make sure that you send location data to your server in bursts, to allows the transmitter to power down.
2 hrs might be too much because the user might be terminating the app and then the updates would never be made. Or if you implement an offline queue, they would only be sent next time the app is started. But that depends on your specific scenario.

It should be cellular tower triangulation, and not GPS location, which is more than enough for your needs. It shouldn't be battery heavy at all.Same with uploading the location, do it rarely and you are fine.
Edit: Confused Core Location with Significant Location.

Related

CLLocationManager geo-fencing/startMonitoringForRegion: vs. startMonitoringForSignificantLocationChanges: vs. 10-minute startUpdating calls

I am trying to set up an app that will be able to check people's locations in the background, see if they are at a given location, and send a ping to a server if they are. We do not want to drain the energy of our users, so we are attempting to figure out the best solution.
I've done substantial reading and I have not found very much information on these methods. I'll go through the pros and cons as I understand them right now
startMonitoringForSignificantChanges
Description: Based off of wi-fi and cell tower changes the system wakes up the app.
Docs:
Apps can expect a notification as soon as the device moves 500 meters
or more from its previous notification. It should not expect
notifications more frequently than once every five minutes. If the
device is able to retrieve data from the network, the location manager
is much more likely to deliver notifications in a timely manner.
Pros:
Most battery efficient
Cons:
Dependent on wi-fi/cell tower changes
Can only assume that this will be called every 200m to 2km (if not more in certain areas)
More on accuracy
Thus, inconsistent and imprecise
10-minute start-updating or "n-minute updating":
Description: This basically asks the app for more time, when that extra time is about to expire, it calls [self.locationManager startUpdating], grabs the location and extends the background thread for 10 more minutes.
Pros:
Consistent
Can be as accurate as you want it to be as consistently as you
want it
Cons:
Has to do a call every ten minutes or less to keep the app running in the
background (ie n can't be greater than 10 for the calls)
Questions:
What effect does this have on the battery? Does waking up the GPS and shutting it off hurt the battery more? I couldn't imagine running a brief location check in the background would drain the battery that much... but then again, I don't know what goes into powering up the GPS and getting a usable signal.
startMonitoringForRegion (geo-fencing):
Simply put, your app gets woken up when you enter into a pre-defined region. This is the oddball of them, it is more recent and there is less documentation on it. I can't find a good description on how the "system monitors" the boundary crossing. For all I know it is some really smart algorithm, or they are constantly pinging the GPS which would make it less effective than the other methods for doing this.
Pros:
Simple implementation
Managed by the system so you don't have to invent your own ad hoc geo-fences Only triggers on boundary crossing... no unnecessary data to just throw out in exchange for a battery hit
Thus, should be the best for this sort of thing, accurate, managed by the system
Cons:
People question its effectiveness
Huge conflicts on whether or not it is good for battery life or if it
drains battery life terribly.
How is the system monitoring this!?
Basically, indeterminate behavior.
I guess my question boils down to how does startMonitoringForRegion: compare to these other methods of testing user location in the background when it comes to battery life, consistency, and precision. Has anyone thoroughly tested this? Or used it in their app and gotten at least some feedback? Likely, for my purposes, the trade-off is between geo-fencing and the 10 minute update method. (Also given what Apple has publicly said about iOS7 there will be some background tasks... will this change the calculus for the trade-off between these two methods?) Does anyone have an idea of how these two compare?
Thanks so much! Looking forward to seeing if we can get to the bottom of how to compare these methods.
I've been working on vehicle tracking using GPS for 2 years. Learned a lot the hard way... In my experience startMonitoringForRegion or Geo-fencing depends upon cell change events, didEnter or didExit events doesn't fire up until there is a cell/wifi change event. So it doesn't make any difference w.r.t battery consumption. However it does extra computation which depends on how many regions currently are being monitored. Even Apple's Reminder app doesn't give good results for location based reminders because it uses geo-fencing.
The other approach starting GPS for n minutes after each m-minutes is good option, it should not affect the battery life, if done wisely. What exactly effect the battery is constant GPS activation in high precision mode. Like for instance If you enable GPS with kCLLocationAccuracyBest and distance-filter = 0, you can literally observe battery drainage and soon your device will also start getting hotter.
If I was you, I would go for activating GPS after every 10 minutes for 5 sec with kCLLocationAccuracyBest (or may kCLLocationAccuracyNearestTenMeters to use less battery, if accuracy is not that much important) and distance-filter = 5 (meters). Battery consumption in this case will be unnoticeable. You can play around with similar settings which can address your specific case and finally find out what is best you.
BTW: iPhone uses AGPS, A-GPS additionally uses network resources to locate and use the satellites in poor signal conditions. So, when you do startUpdatingLocation it will also use nearby cell tower information. see http://en.wikipedia.org/wiki/Assisted_GPS

iphone - What consumes less battery? StartmonitoringLocationsChanges or startmonitoringforregion?

I would like you to give me your feedback on which method consumes less battery.
My app will run in the background and will wake up with location changes, so I would like to use the method that consumes less battery.
Any ideas on which one it is?
Thanks
Neither of these choices is responsible for more or less battery consumption.
In order for your app to be notified of any location update, regardless of whether it is for a region change or a significant location change, you must specify in your app's Info.plist file that you will require location-services in the background.
There are actually two relevant choices for location services: location-services or gps.
In order NOT to drain the user's battery, choose location-services. If you say your app needs gps background services, you WILL drain the battery because this will cause the GPS hardware (assuming it is present) to be enabled, and THAT is the cause of battery drain. When you specify location-services, the device uses the cellular radio (which is on anyway, assuming you have an iPhone) to pinpoint the location instead. Not as accurate as gps, but most apps don't need GPS accuracy. (If you do, then use gps, of course, but know the consequences vis a vie battery life.)
I recently wrote a test app all about this (and I wrote about it last week here) and what I found was there was no significant battery drain when I had several regions setup for monitoring and I specified location-services as a required background service.

Time based GPS location in background (iphone)

I want to create an (game based) iPhone application which sends your GPS location on a specific time (like 3-5 times a day) to a server. I found an apple page explaining some functionality to run in the background like location, music and VOIP.
I need the GPS to be accurate on the meter.
Can someone help me with a small example?
It really depends on your usage of the location. If you monitor actively, kiss the battery of your user goodbye. Very detailed accuracy, even bigger hit to battery. The backgrounding of location is all or nothing as far as accuracy goes.
Less hit, less accuracy is -startMonitoringForSignificantLocationChange. May not be accurate enough for you.
Better depending on usage, region monitoring. Triggers event on entry or exit of defined region.
You don't have the benefit of accuracy and timed location based events. You can do it, but is going to require a lot more effort on your end.
While this is untested, I am planning an app with a similar need. My solution is that on a significant location change, the app will determine what interval exists between the update timestamp, and when I care to know the users location (5pm for instance). If that's below some threshold, it will go into startUpdatingLocation mode (full power, battery draining, which is why that threshold is important) and then, on each location update, check if that target time has passed. if SO, send the update to your server, and go back to monitoring for significant changes. The catch is that if it still requires some movement to trigger the significant change update...so it isn't a perfectly reliable solution, but it may work depending on how you're using the data
You can't "schedule background work". iOS doesn't allow it.
The solution is to set yourself up for notification on significant change (which is some hit to the battery, but it's not horrible), and then only DO anything with that at occasional intervals.

Background app drains too much battery

I have developed an application for iPhone that runs in the background with GPS mode on. I need to ask the server if there are any new tasks for the user? Fir this purpose, I have added the code in the didUpdateToLocation method. Now the problem is that it consumes the battery very fast. Please guide me how to avoid the battery consumption. Also, I need to keep the location accuracy at best.
Also, is there any other way where I can communicate to the server even while the app is running in the background. Please help me, I will be really grateful.
It is impossible to get accurate location without using internal GPS in the current state of iPhone. Since essentially you are keeping the GPS alive during the running of the app (not sure if Multitasking API allows GPS calling in background though), it would consume lots of battery power without doubt.
In this case, you either have to avoid calling GPS as much, or live with coarse locations from the cellar towers. You can't have both frequent GPS results and nice battery consumption.

iPhone background task periodically

I have and issue where i want to collect GPS data periodically, say every 5 minutes. I can do this no problem when the app is running. However i wanted to know if there is a standard way to do this using the iPhone 'multitasking'. I can collect the data using the background process using the constant updating model and the significant changes, but these are either too battery intensive or to inaccurate.
I am in the process at looking the the NSLocalNotification, how ever i'm not sure the keeps the app in a background state while checking location periodically, i think this only has the option of launching the app.
Thank in advance.
There is no way to perform periodically GPS acquisition (each 5 min for example).
From Apple documentation:
Tips for Conserving Battery Power
Receiving and transmitting data using the radios of an iOS-based device require more power than any other operation on the device. Because Core Location relies on these radios to determine the user’s location, you should use location services judiciously in your applications. Most applications do not need location services to be running all the time, and so turning off those services is the simplest way to save power.
Turn off location services when you are not using them. This may seem obvious but it is worth repeating. With the exception of navigation applications that offer turn-by-turn directions, most applications do not need location services to be on all the time. Turn location services on just long enough to get a location fix and then turn them off. Unless the user is in a moving vehicle, the current location should not change frequently enough to be an issue. And you can always start location services again later if needed.
Use the significant-change location service instead of the standard location service whenever possible. The significant-change location service provides significant power savings while still allowing you to leave location services running. This is highly recommended for applications that need to track changes in the user’s location but do not need the higher precision offered by the standard location services.
Use lower-resolution values for the desired accuracy unless doing so would impair your application. Requesting a higher accuracy than you need causes Core Location to power up additional hardware and waste power for precision you are not using. Unless your application really needs to know the user’s position within a few meters, do not put the values kCLLocationAccuracyBest or kCLLocationAccuracyNearestTenMeters in the desiredAccuracy property. And remember that specifying a value of kCLLocationAccuracyThreeKilometers does not prevent the location service from returning better data. Most of the time, Core Location can return location data with an accuracy within a hundred meters or so using Wi-FI and cellular signals.
Turn off location events if the accuracy does not improve over a period of time. If your application is not receiving events with the desired level of accuracy, you should look at the accuracy of events you do receive and see if it is improving or staying about the same over time. If accuracy is not improving, it could be because the desired accuracy is simply not available at the moment. Turning off location services and trying again later prevents your application from wasting power.