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 e开发者_如何学Crror 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!
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
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.
精彩评论