Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notifications for changes to Location Services?

I've been experimenting with CLLocationManager for an app I'm building. I understand how to check if Location Services are enabled and whether or not a user has allowed my app to use their current location.

If a user allows my app to use their location initially, and then the user either:

  1. turns location services off explicitly
  2. puts the phone in airplane mode
  3. explicitly de-authorizes my app to use their location

Are any notifications posted that I can subscribe to and respond to automatically when they reopen my app?

If not, would the best way to handle this scenario (so I can update views that were displaying GPS coordinates) to manually put this check in my AppDelegate's applicationDidFinishLaunching and applicationWillEnterForeground methods?

The reason I was thinking it should go there is because when you relaunch an app, viewWillAppear is not triggered for the first view, and if that view needs to change from showing GPS coordinates to a friendly message asking them to re-enable location services, the AppDelegates were the best hook I could think of.

Thanks!

like image 467
djibouti33 Avatar asked Feb 08 '11 09:02

djibouti33


1 Answers

On iOS 4.2 and later you will get a delegate call

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
like image 63
tomislav Avatar answered Sep 30 '22 02:09

tomislav