3

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

jimmym715
  • 1,512
  • 1
  • 16
  • 25
subharb
  • 3,374
  • 8
  • 41
  • 72

1 Answers1

5

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.

Mark Granoff
  • 16,878
  • 2
  • 59
  • 61
  • Do I have to set in the info.plist that the app should use Location-services? If I dont it will use the GPS?, because I havent done that Also, what is more accurate "Location Changes" or "Region Changes"? BTW, great post! – subharb Apr 03 '12 at 10:05
  • 1
    To clarify, your app must have 2 things in its Info.plist: Under "Required background modes" you must say that your app will register for location updates, and under "Required devices capabilities" you should put __location-servics__. You could put __gps__ here instead, but that will drain the battery. This latter setting also helps prevent users with devices without the necessary hardware (e.g. a cellular antenna) from downloading your app. – Mark Granoff Apr 03 '12 at 12:23
  • So it doesnt improve the performance of the app, right? It will trigger "didUpdateLocation" the same amount of times. Also, which one is more accurate Location Changes or Region Changes? Im not getting many location changes, so Im thinking of switching to Region Monitoring, how many regions can you add? thanks. – subharb Apr 03 '12 at 13:48
  • The frequency of location updates to your app is dependent on whether you required __location-services__ or __gps__; I don't think the CLLocationManager accuracy setting is taken into account in this case. The use cases for Location Changes and Region Changes are different, so which to use really depends on what your app is doing. Monitored regions are a global thing, so there is a practical limit (undocumented) to the number of regions you can or should monitor at one time. I'd keep it to a small number, say under 10. "Required device capabilities" has no impact on performance, AFAIK. – Mark Granoff Apr 03 '12 at 14:21
  • If it can handle upto 60 regions It could work for me. Using location services the app will not detect a change in their location unles it moves more than 500 metres, I was wondering if with geofencing the trigger will start right after leaving the region, if so then it's work a try. Do you know that? Thanks – subharb Apr 03 '12 at 15:47
  • 60 might be pushing it. The docs recommend that you remove monitored regions when you no longer need them, and create them as you are about to need them. I suspect that works well if you have a route and know where you're going and where you're been. You cannot count on location change updates arriving instantaneously when you cross a region boundary. "Soon", but not "instantaneous." You should review the docs on this carefully to understand the nuances (in what little the docs do say...) – Mark Granoff Apr 03 '12 at 16:23
  • Nice answer, and a great article that you wrote. I'll be coming back to read that article again soon, I'm sure! – Grezzo Feb 03 '14 at 23:47