Fix/ios background permission reset #1511
Open
+30
−0
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.
Issue
IOS permission request state not being reset when app enters background, causing subsequent requests to fail with ERROR_ALREADY_REQUESTING_PERMISSIONS.
Video : https://github.com/user-attachments/assets/0f78390a-cbd3-4362-87c8-2874ae4ac620
Changes:
Reproduction Steps (Before Fix)
await Permission.location.request()await Permission.location.request()againERROR_ALREADY_REQUESTING_PERMISSIONSExpected Behavior
If the app is backgrounded during a permission request:
REQUEST_INTERRUPTED)_methodResult = nil)ERROR_ALREADY_REQUESTING_PERMISSIONSActual Behavior (Before Fix)
_methodResult != nil)ERROR_ALREADY_REQUESTING_PERMISSIONSSolution
UIApplicationDidEnterBackgroundNotificationwhen plugin initializesREQUEST_INTERRUPTEDerror and reset internal stateAfter Fix
Same reproduction steps now work correctly:
await Permission.location.request()await Permission.location.request()againPre-launch Checklist
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.CHANGELOG.mdto add a description of the change.///).main.dart format .and committed any changes.flutter analyzeand fixed any errors.