Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLLocationManager don't stop

Dear fellow developers,

I am trying hard to find a solution for my problem regarfing CLLocationManager.

I use a CLLocationManager instance in my Application. If the user selects the Home button on the device or terminates the application I want the location services to stop.

Therefor I call [self.locationManager stopUpdatingLocation]; - But this somehow doesn't work. The application enters the background and the small location arrow in the upper right corner of the status bar don't disappear. Even if I add [self.locationManager release] or self.locationManager.delegate = nil; - the location tracking don't stop :-/

It only disappears if I go to my device settings and switch off location services for the app. Whenever I switch back to location service enabled I immediately get a purple colored arrow next to the switch toggle and the icon reappears in the status bar.

My question is how can I turn off location services when the app enters the background or is terminated?

Thanks a lot in advance and have a nice day :-)

like image 254
MrBr Avatar asked Nov 16 '11 16:11

MrBr


2 Answers

Your location is disabled. The location service icon "meaning" has changed on iOS 5. Take a look at this question: https://apple.stackexchange.com/questions/27463/why-is-the-location-services-icon-always-present

I Quote the answer:

It's a new feature in ios 5 called "region Monitoring"

The reason it's active even if the app is closed is that this feature runs in iOS 5 core and notifies all apps that are registered when they have entered or left a specific geo-fence.

Reminders does that when you use a location based reminder.

Although the location icon appears at all time. This actually has very minimal impact on the battery due to apple really optimizing this feature by using cell and wifi mostly.

Your app is working ok. The system behaviour is the one who changed.

like image 72
Sergio Moura Avatar answered Sep 29 '22 14:09

Sergio Moura


You do it the right way. When entering background, it's ok if some delegate methods are called for some seconds. That should stop.

Where do you stop the location updates ? Are you sure it is triggered ? If yes, are your delegate method called even if the visual indicators tell something else ?

Are you sure you don't trigger a method that reactivate the location update after you have stopped it (because for example you can receive some updates even after stopped).

like image 38
Oliver Avatar answered Sep 29 '22 15:09

Oliver