Reputation: 21
So I have a pretty weird problem here.
The first time my app is installed it prompts the user "MyApp would like to use your current location", I clicked OK and location manager works fine after that.
Then I try rebuilding the app again and run it. This time it is not receiving any location updates in the location manager delegate function whereas before it did:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)
In my .plist I have the Required background modes key set to "App registers for location updates" and Required device capabilities key with "gyroscope", "location-services", "accelerometer" and "gps".
Also I checked settings and in Location Services it is indeed turned on. Also I'm doing the following check and it is returning true:
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) {
// rest of the code
}
I can reproduce this issue again and again by deleting the app and reinstall it. It would work the first time when it prompts to use your current location, but as soon as I rebuild and run it again, it fails.
Any ideas would be appreciated, thanks.
Upvotes: 1
Views: 245
Reputation: 9768
If building against the iOS 8 SDK, I think you also need to call either requestWhenInUseAuthorization
or requestAlwaysAuthorization
too.
Upvotes: 1