views:

267

answers:

2

My application asks for location at the log in screen, and right now, the user can log in without sharing his or her location. When the user selects "No" for sharing location, an error that reads Error Domain=kCLErrorDomainCode=1 "The operation couldn't be completed. (kCLErrorDomain error 1.)" is thrown. I'm guessing that's because I am trying to access latitude and longitude without having such things.

My question is, how do I make sure that a user allows location before anything else can be done? Is there a way to create a new "Allow Location" pop-up request?

Thanks in advance!

A: 

My suggestion would be have your application cope with the situation where no location information is available, by informing the user that this is a requirement etc.

Repeating the dialog until you get the answer you want is just going to annoy the user.

Garry
Can I do something like "Click here to allow location"? If so, how? My problem is that the Allow Locations request is shown only once right now. Thanks.
ayanonagon
A: 

You would need to implement locationManager:didFailWithError.

The documentation states that:

If the user denies your application’s use of the location service, this method reports a kCLErrorDenied error. Upon receiving such an error, you should stop the location service.

Additional information is here

Shaji
That is exactly what I was looking for. Thank you!!
ayanonagon
I was under the impression that if a user relaunches an app, it would prompt the user again to allow location. I just tried it, and that does not seem to be the case. What can I do to get around this? Thanks again!
ayanonagon
@ayanonagon you should inform the user everytime when you get the KCLErrorDenied error that location services are required for your application or for certain functionality and they should grant the application permission via the settings app.
Shaji
Ah! I had no idea that such a page even existed in the settings page :X I will notify my users to do that. Thank you so much.
ayanonagon