fix(ios): recognize NSLocationAlwaysAndWhenInUseUsageDescription - #1073
Merged
Conversation
requestPermission() only checked the pre-iOS 11 NSLocationAlwaysUsageDescription key to decide whether Always authorization could be requested, never the current NSLocationAlwaysAndWhenInUseUsageDescription key -- the one this plugin's own README recommends. An app declaring only the modern key was treated as having no usage description at all, so requestPermission() fell through to a warning log instead of prompting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #962 —
requestPermission()'s internalrequestPermission()(native, not the public Dart method) only checkedInfo.plistfor the pre-iOS 11NSLocationAlwaysUsageDescriptionkey to decide whether it's allowed to callrequestAlwaysAuthorization(). It never checkedNSLocationAlwaysAndWhenInUseUsageDescription— the modern key Apple has required since iOS 11, and the one this plugin's own README recommends adding.Concretely: an app that follows Apple's current guidance and declares only
NSLocationAlwaysAndWhenInUseUsageDescription(without also adding the legacyNSLocationAlwaysUsageDescription) was treated by this check as having no always-usage description at all. If it also has noNSLocationWhenInUseUsageDescription,requestPermission()falls through to anNSLogwarning and never prompts the user at all.Fix:
hasAlwaysnow checks both keys.Verification
flutter build ios --simulator --no-codesignandflutter build macos --debuginpackages/location/example— both build clean (shared Darwin source).macos/Runner.xcodeprojchurn from the build so the diff is feature-only.Bundle.main.object(forInfoDictionaryKey:)check the issue points at, against Apple's documentedInfo.plistkeys.