Alpstein/route-me — pull request #106 by noberasco (2012-10-09 14:00:30+00:00)
Title: Fix CLLocationManager management

Hi,

there is a bug in Alpstein/route-me management of CLLocationManager.

Basically, if userTrackingMode is set to either RMUserTrackingModeFollow or RMUserTrackingModeFollowWithHeading, a CLLocationManager is instantiated to keep track of location changes.

So far so good.

However, if application is registered to get location updates in background, when application enters background mode, this location manager does not get deactivated, meaning that the GPS receives is kept active, draining the battery needlessly.

I'll explain better with an example. I have an application (EasyTrails, basically a GPS tracker) that is registered to receive location updates in background. However, I keep the location manager active in background only while the user is actually recording a track, otherwise the application will be sent to background just like any other application. Your use of CLLocationManager disrupts this behavior, since your instance of CLLocationManager does not get deactivated when application goes into background.

This pull request does just that: it registers with UIApplication status updates so that it can disable, if needed, the location manager when entering background mode and reenable it when application returns to foreground.