views:

65

answers:

1

This afternoon I walked my iPhone 4 into the Apple Store to see if they could help with a problem I've been having. Battery life hasn't been AT ALL what it should be--the battery drops 50% sitting on my desk overnight. Crazy. So I suspect I've got a bum unit. Happens. No biggie.

My friendly genius pokes around my phone a bit, and points out that the Location Services pointer is lit in the top right corner of the screen. He gets into the location services settings. He notes that the following apps have the "got location data in the last few hours" flag lit: The Weather Channel, Showtimes, and two apps I wrote and am days away from submitting.

He turns off the sliders for each of those apps, and we see the top corner location services pointer turn off. Turning back on location services for EITHER of my apps makes it turn back on, and that's NOT the case for Weather Channel or Showtimes. But it's clear that turning on location services for my two apps fires up the device's location services. My lousy battery life is explained, but that's just the beginning of the mystery.

Here's the thing.... Neither of my apps are EVEN RUNNING at the time. They're not even backgrounded. They're OFF. I think they're both built in a debugging profile on my device at the moment, and they both do use Core Location. They're not suspended, they're just flat not running. And yet, turning on the slider in the location services control panel for either of them fires up location services in general.

So... What the heck is happening here? Neither of those apps are configured for background location. And... they're not IN the background! And since I've had location services turned off for them, there's no doubt my battery usage is way way down.

+1  A: 

The solution is at this thread in the Apple developer forum: https://devforums.apple.com/thread/58063?tstart=0

An earlier version of both of these apps had called [locationManager startMonitoringSignificantLocationChanges], and never called stopMonitoring.... Even though the current version of the apps didn't make that call, the OS still had the monitoring request "registered" to the apps (and was, in fact, relaunching them in the background as I drove around town!).

What I didn't know was that the monitoring request persists across launches--and across re-builds! I'd assumed that, like -startUpdatingLocation, the monitoring request would die with the process, but not so. The solution was to delete the apps from my device and reinstall.

Dan Ray