I am calling for current location whenever the user logs in, and at several other places. Whenever I do so, the alert view asking for permission by the user appears for a second or so, and then it gets disappeared. And obviously, I don't get the location. this happens every time I prompt for location. It does not allow the user to click Cancel or OK. Please help
It's likely that you were not retaining the locationManager. As a consequence, when you called [CLLocationManager startUpdatingLocation]
the alert was shown but it disappears as soon as the locationManager is released. It happened to me once when I typed assign instead of strong into the property I had created for my locationManger instance.
Same problem am faced in my project(swift lang).
try this, Declare that CLLocationmanage variable as global variable and call where you want.
ex:
var locManager = CLLocationManager()
override func viewDidLoad()
{
super.viewDidLoad()
let iOS7 = floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_7_1)
let iOS8 = floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1)
locManager.delegate = self
locManager.desiredAccuracy = kCLLocationAccuracyBest
if(iOS8)
{
locManager.requestAlwaysAuthorization()// only support ios 8.0
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With