DanClowdy
DanClowdy

Reputation: 31

iOS7 and iOS 8 location services

I have an app and I want to add some location based features to it. It supports both iOS 7 and 8, but I'm having some issues.

I want to request the permission for location only when the user taps a certain button on a certain viewController. The issue is that the permission request appears as soon as the app launches. To be more precise, between ViewWillAppear and ViewDidAppear functions of the first viewController.

What I have tried previously:

  1. having the NSLocationWhenInUseUsageDescription key in the plist (for iOS8). In terms of code:

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self.locationManager.delegate = self;
    if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [self.locationManager requestWhenInUseAuthorization];
    }
    [self.locationManager startUpdatingLocation];
    
  2. Removing the plist key -> this caused the pop up in iOS8 not to appear anymore, but it still does in iOS7

At the moment every single bit of code related to CoreLocation is commented out and I still do get the dialog asking me for permissions (iOS7 only)

I don't know what else I could possibly try, so any bit of help is much appreciated

Upvotes: 2

Views: 278

Answers (2)

DanClowdy
DanClowdy

Reputation: 31

Ok, I discovered the issue. It turns out that a third party app is requesting permissions as soon as the app opens. Thank you for all the answers.

Upvotes: 1

matt
matt

Reputation: 535139

That's just how iOS 7 (and before) works. You're not in charge of the authorization dialog: the system is. You can't make it appear; the system, seeing that you are using Core Location, presents it on your behalf. That is exactly the sort of thing that iOS 8 changes. All you can do in iOS 7 is look to see whether location services are turned on and whether your app is authorized.

Upvotes: 1

Related Questions