Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for when in use only. #1295

Merged
merged 5 commits into from
Mar 26, 2024
Merged

Conversation

mvanbeusekom
Copy link
Member

  • Adds the PERMISSION_LOCATION_WHENINUSE marco, which can be used instead of
    the PERMISSION_LOCATION macro and only enable the requestWhenInUseAuthorization
    and remove the requestAlwaysAuthorization when requesting location permission.
  • Improves error handling when Info.plist doesn't contain the correct declarations.
  • Adds support for the NSLocationAlwaysAndWhenInUseUsageDescription property list
    key.

Pre-launch Checklist

  • I made sure the project builds.
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I rebased onto main.
  • I added new tests to check the change I am making, or this PR does not need tests.
  • I made sure all existing and new tests are passing.
  • I ran dart format . and committed any changes.
  • I ran flutter analyze and fixed any errors.

permission_handler_apple/CHANGELOG.md Outdated Show resolved Hide resolved
permission_handler_apple/CHANGELOG.md Outdated Show resolved Hide resolved
[_locationManager requestAlwaysAuthorization];
} else if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] != nil) {
[_locationManager requestWhenInUseAuthorization];
} else {
[[NSException exceptionWithName:NSInternalInconsistencyException reason:@"To use location in iOS8 you need to define either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in the app bundle's Info.plist file" userInfo:nil] raise];
errorHandler(@"MISSING_USAGE_DESCRIPTION", @"To use location in iOS8 you need to define at least NSLocationWhenInUseUsageDescription and optionally NSLocationAlwaysAndWhenInUseUsageDescription in the app bundle's Info.plist file");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in iOS 8 or from iOS 8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good comment, it should be "from" and I have pushed an update.

} else if (permission == PermissionGroupLocationAlways) {
if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] != nil) {
#if PERMISSION_LOCATION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this PERMISSION_LOCATION correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is correct. The existing PERMISSION_LOCATION macro enables "when in use" and "always" permissions. I didn't want to rename it as that would be a breaking change.

Copy link
Contributor

@TimHoogstrate TimHoogstrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mvanbeusekom mvanbeusekom merged commit 59fee21 into main Mar 26, 2024
1 check passed
@mvanbeusekom mvanbeusekom deleted the fine_grained_location_permission branch March 26, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants