Baseflow / Baseflow/flutter-permission-handler

[Bug]: Requesting locationAlways does not await user's response.

Open
#1,152 8 comments 9 reactions 1 assignee Claimed by @mvanbeusekom View on GitHub
P2 platform: ios refactor type: bug
Dominant language
Dart
Stars
2.2k
Forks
970
Avg merge
14h 22m
Merged PRs (30d)
2

Description

### Please check the following before submitting a new issue.

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-permission-handler/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [ ] Android
- [X] iOS
- [ ] Windows

### Steps to reproduce

1. Check result of requesting locationWhenInUse permissions `await Permission.locationWhenInUse.request()`.
2. Check result of requesting locationAlways permissions `await Permission.locationAlways.request()`.

### Expected results

We expect the both requests to properly await the user's response to the iOS system dialog, and returns the user's choice.

### Actual results

In the above steps, the first request properly awaits the user's response to the iOS system dialog, and returns the user's choice.

The second request immediately returns a response of not granted because the user hasn't responded yet to the dialog.

### Code sample

```dart
Future _requestLocationWhileInUse() async {
// This actually waits for user to respond to dialog prompt before
// continuing to return the status.isGranted.
final status = await Permission.locationWhenInUse.request();

return status.isGranted;
}

Future _requestLocationAlways() async {
// This does not wait for user to respond to dialog prompt before
// continuing to return the status.isGranted, thus, we often receive
// false here, and have to check after the user responds to the dialog.
final status = await Permission.locationAlways.request();

return status.isGranted;
}
```

### Screenshots or video

Screenshots or video demonstration

[Upload media here]

### Version

10.4.3 - 11.0.0

### Flutter Doctor output

Doctor output

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.5.1 22G90 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.81.1)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.