Open MagdyEl-Sayed opened 2 years ago
Hi @MagdyEl-Sayed, is it possible for you to share your code so I can see where this messages comes from? If you want to ask multiple permissions at the same time, you should request them as follow:
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
Permission.storage,
].request();
print(statuses[Permission.location]);
I hope this helped you out, let me know if it worked!
if i select denied and request permission again , it return exception message "request for permissions is already running"
Hi @MagdyEl-Sayed, can you share some more information please?
I would like to see a minimal code snippet to reproduce the issue and the flutter doctor -v
output.
if i select denied and request permission again , it return exception message "request for permissions is already running"
same here, exception is thrown for the deny-case only.
final Permission _permission = Permission.locationWhenInUse;
final PermissionStatus status = await _permission.status;
if (!status.isLimited && !status.isGranted) {
// Ask user for permission. If it has already been granted before, nothing happens
final PermissionStatus result = await _permission.request();
if (result.isPermanentlyDenied) {
onPermanentlyDenied.call();
return;
}
if (!result.isGranted) {
return;
}
}
onGranted.call();
Same issue here
Same issue here!
Maybe this will help someone ...
I had exactly same issue (IOS emulator only ) (Android works fine)
I managed to finally fix this on IOS emulator side...
Removed background permission for IOS in info.plist
and only left this one:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires access to your location information to operate</string>
then finally cold run and i get the permissions dialog...select allow once or when using app and seems to be fine.
I experience the same bug although I'm requesting the same permission multiple times, e.g.
I defined a method which retrieves the location and checks if permission has been granted. I do this as I had crashes when requesting the location after running the permission request as a quick fix for now
Future<LocationData?> getLocation({LocationAccuracy accuracy = LocationAccuracy.high}) async {
final granted = await ph.Permission.locationWhenInUse.isGranted;
if (!granted) {
final result = await ph.Permission.locationWhenInUse.request();
Fimber.e('location has not been granted');
return null;
}
final location = Location()..changeSettings(accuracy: accuracy);
return location.getLocation();
}
and in another place I try to update the location as fast as possible by running:
// Request one location precision after the other to reduce location update time
final lastKnownLocation = await getLocation(accuracy: LocationAccuracy.powerSave);
if (lastKnownLocation != null) {
emit(OnLastKnownLocation(location: lastKnownLocation));
}
final normalLocation = await getLocation();
if (normalLocation != null) {
emit(OnLocation(location: normalLocation));
}
final bestLocation = await getLocation(accuracy: LocationAccuracy.navigation);
if (bestLocation != null) {
emit(OnLocation(location: bestLocation));
}
So somehow awaiting the permission response didn't really finish the request.
It might be not the best code but I guess it illustrates the problem quite well.
Same issue here!
@MagdyEl-Sayed
I've experienced the same issue and found a solution.
Did you override onRequestPermissionsResult
in your MainActivity
?
My fix is adding a fallback on a not managed requestCode
like this snippet.
Without the fallback, the PermissionManager.onRequestPermissionsResult
is never called and the plugin is not updated about the permission result.
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
when (requestCode) {
myRequestCode -> myFunction(myRequestCode)
else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
cc: @JDDV
Same issue here.
flutter SDK 2.10.3 permission_handler: 10.2.0 or 11.0.1
device: Android 13
static Future<bool> locationGranted() async {
bool isGranted = true;
Map<Permission, PermissionStatus> statuses = await [
Permission.location,
].request();
statuses.forEach((key, permission) {
if(permission.isDenied){
isGranted = false;
}
});
return isGranted;
}
我也遇到了同样的问题,升级到11.0.1后作者解决了这个问题
Same issue here,and the problem was solved after upgrading to 11.0.1
Same issue here,and the problem was solved after upgrading to 11.0.1
Same issue.
I try to update permission_handler: ^11.1.0
, still alive this problem.
i was facing same in fcm..i double checked we are not requesting permission more than once but is still facing this issue..however we are not facing crashes so I have left it open.. The issue probably is in new flutter version and a migration is needed.. we will do it later but until then the app works just fine..
Any suggestions are most welcome..
Same issue is occurring on Android. I also tried the latest version of permission_handler
11.3.1.
PlatformException(PermissionHandler.PermissionManager, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null, null).
I'm encountering an issue when the app requests SMS permission after obtaining location permission.
我也遇到了同样的问题,升级到11.0.1后作者解决了这个问题
Same issue here,and the problem was solved after upgrading to 11.0.1
11.0.1依然存在这个问题
A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time).