0

I want to show the message which asks the user if he accepts that the application will use the location services in his device. How can i implement that, WITHOUT saving his location? I've tried to do startLocationUpdates and then stopLocationUpdates, but that doesn't work. If i remove the stopLocationUpdates, that works, but the location indicator remains in the status bar.

If you ask why i need this, I'm using Core Location methods few screens later. Before using them, i check for + (CLAuthorizationStatus)authorizationStatus , and if it's different from "Authorized", i give an alert message. Is that wrong ?

Thanks !

ozking
  • 438
  • 1
  • 5
  • 12

1 Answers1

0

I suppose that you call to startLocationUpdates and then stopLocationUpdates in the same method?

If this is the case then try the following:

// Assuming that you have a property called locationManager
// If you don't then you should at least have an initiated member 
// in order to succeed with the second line below
[self.locationManager startUpdatingLocation];
[self.locationManager performSelector:@selector(stopUpdatingLocation) withObject:nil afterDelay:0.1];

This way the stopLocationUpdates method will be called in the next runloop.

Michael Kessler
  • 14,245
  • 13
  • 50
  • 64
  • Thanks, that works! I've just had to change the delay to 0.2, because sometimes it worked and sometimes not. – ozking Nov 16 '11 at 13:53
  • Hey, will it be approved by apple? A quote from apple guidelines: "4.1 Apps that do not notify and obtain user consent before collecting, transmitting, or using location data will be rejected" – ozking Nov 16 '11 at 17:29
  • The app will automatically prompt the user from the OS for permission to use location. You should be fine. – Bill Burgess Nov 16 '11 at 19:31
  • @BillBrasky, That's alert of "Location Authorization" is only available is only available on ios 4.2 and later, isn't it ? – ozking Nov 17 '11 at 13:18
  • No, the authorization should be there for all devices 4.0 and up. – Bill Burgess Nov 17 '11 at 13:44