This repository was archived by the owner on Oct 5, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 36
This repository was archived by the owner on Oct 5, 2021. It is now read-only.
[android] "Can request only one set of permissions at a time." #53
Copy link
Copy link
Open
Description
🐛 Bug Report
Calling await LocationPermissions().requestPermissions(); with both "Fine" and "Coarse" permission in AndroidManifest.xml gives the Can request only one set of permissions at a time. in the logs. Also, giving PermissionStatus.denied (even if approved) when checkPermissions called after awaiting requestPermissions.
Expected behaviour
The error/warning should not come in and correct status should be returned by checkPermissions after requestPermissions is called.
Reproduction steps
Code to reproduce:
Future<bool> _checkLocationPermission() async {
final checkPermission = await LocationPermissions().checkPermissionStatus();
printIfDebug("checkPermission: $checkPermission");
if (checkPermission == PermissionStatus.granted ||
checkPermission == PermissionStatus.restricted) return true;
return false;
}
Future<bool> _checkAndRequestLocationPermission() async {
// return true, if already have permission
if (await _checkLocationPermission()) return true;
// request permission
final _ = await LocationPermissions().requestPermissions();
printIfDebug("requestPermission: $_");
// check if permission was given
final hasPermission = await _checkLocationPermission();
// if no permission and "showShowPermissionRationale" then go to settings and return false
if (!hasPermission &&
await LocationPermissions().shouldShowRequestPermissionRationale()) {
// if shouldRequest false, then open app settings and return false
// TODO UI that shows why this permission is required
await LocationPermissions().openAppSettings();
return false;
}
return hasPermission;
}This is how it it is used for checking access for location before calling WifiManager.startScan api on android
Future<List<WifiNetwork>> scanWifi() async {
if (await _checkAndRequestLocationPermission())
return await WiFiForIoTPlugin.loadWifiList();
return null;
}Configuration
Android SDK: 28
Version: ^3.0.0
Platform:
- 📱 iOS
- 🤖 Android
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels