intuit / LocationManager

Easily get the device's current location on iOS.
MIT License
2.56k stars 387 forks source link

Updating permission level #93

Closed ryanthon closed 6 years ago

ryanthon commented 7 years ago

Hi, So our app currently requests "when in use" permissions, but on the next release, we are planning to bump it up to "always" permissions. However, it looks like INTULocationManager never actually tries to request "always" permissions if "when in use" has already been requested. The only time any permissions are requested at all are when permissions have not yet been determined.

So I'm wondering, would it be possible to change the logic in the requestAuthorizationIfNeeded() method to request "always" permissions if only "when in use" was asked previously?

Something like:

BOOL hasAlwaysKey = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] != nil;
BOOL hasWhenInUseKey = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] != nil;

if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
    ...
} else if (hasAlwaysKey && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) {
    [self.locationManager requestAlwaysAuthorization];
}

I figure this will cover the use case I've mentioned, and should work as the existing intended behavior since iOS won't show the permissions dialog more than once.

Any thoughts?

lwdupont commented 7 years ago

This seems like a reasonable request to me. Are you interested in doing a pull request for it?

lwdupont commented 6 years ago

This is fixed in the latest released version.