Current location permission dialog disappears too quickly
Same symptom, different cause: do not to call startUpdatingLocation
more than once in a row.
I had accidentally structured things such that the code was unintentionally calling startUpdatingLocation
twice in a row, which is apparently bad. It might also have had something to do with choice of queue since I was waiting to start updating pending the result of a network request, but I didn't need to do any GCD magic to fix it...just needed to make sure I didn't repeat the start.
Hope someone's able to benefit from my pain. :)
While difficult to track down, the solution for this is quite simple.
Through much trial and error I found out that while the location access dialog pops up when you try to access any location services in the app for the first time, the dialog disappears on its own (without any user interaction) if the CLLocationManager
object is released before the user responds to the dialog.
I was creating a CLLocationManager
instance in my viewDidLoad
method. Since this was a local instance to the method, the instance was released by ARC after the method completed executing. As soon as the instance was released, the dialog disappeared. The solution was rather simple. Change the CLLocationManager
instance from being a method-level variable to be a class-level instance variable. Now the CLLocationManager
instance is only released once the class is unloaded.