Thibaut LE LEVIER
Thibaut LE LEVIER

Reputation: 245

CLLocationManager disable monitoring significant changes in background

I'm using background geolocation to schedule local notifications when the user is in a specific location.

Since theses notifications are link to a commercial operation I've got a date, stored in the userdefaults to manage when I should disable the background geolocation when the operation is other.

I don't want the user to have to launch the application to be able to disable the significant changes monitoring.

So I tried to stopMonitoringSignificantLocationChanges the CLLocationManager directly in the locationManager:didUpdateToLocation:fromLocation: but it doesn't seam to work.

Any advice? What is the best practice for this issue?

Thanks.

Upvotes: 0

Views: 245

Answers (1)

Bill Burgess
Bill Burgess

Reputation: 14164

Given the rules of the road for backgrounded applications or apps that aren't running, your hands are somewhat tied here.

Here is your one and only option if you want to disable location without any interaction from the user.

Each time your user's location updates from the background, your location manager delegate will receive this update. You don't get a lot of processing power here, so keep it short and sweet or register for a long running background task, check your date and if you are done with location, call the stop monitoring call there, reset any data or flags in your user defaults and you are done.

If you trigger from a local notification, the user will need to click on the open button to perform any actions. You can fire notifications from your background location delegate method for sure. But that is your one and only path to automating anything without user interaction. What you do there is up to you. There is no problem with checking for location udpates and turning that off from the background delegate method.

Upvotes: 0

Related Questions