flutter-permission-handler
flutter-permission-handler copied to clipboard
[PermissionRequestInProgressException] LocationAlways throws ERROR_ALREADY_REQUESTING_PERMISSIONS
🔙 Regression
Old (and correct) behavior
Permission.locationAlways.request() was working.
Current behavior
Permission.locationAlways.request() throws an error:
Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, 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)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18)
<asynchronous suspension>
#2 MethodChannelPermissionHandler.requestPermissions (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:71:9)
<asynchronous suspension>
#3 PermissionActions.request (package:permission_handler/permission_handler.dart:44:31)
<asynchronous suspension>
#4 FuturePermissionStatusGetters.isGranted (package:permission_handler_platform_interface/src/permission_status.dart:90:40)
<asynchronous suspension>
#5 _MapBoxScreenState.startGeofences (package:aschaffenburger_geschichten/screens/discover/map_box.dart:434:8)
<asynchronous suspension>
Reproduction steps
Future<void> getPermission() async {
if(await Permission.locationWhenInUse.request().isGranted){
await Permission.locationAlways.request();
}
}
Configuration
Version: 8.3
Platform:
- [ x] :iphone: iOS
- [ ] :robot: Android
flutter doctor:
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-arm, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability
The plugin is setup according to the instructions. I added "PERMISSION_LOCATION=1"
to my Podfile
and have all necessary keys and strings in my Info.plist
.
Hi!
I also have this issue on iOS but on Android everything works fine. Request locationAlways is never finished, I have tried to add the timeout but it throws an exception.
Do you have any idea how to fix this?
Really nothing? Is this package even still under maintenance? This is a serious issue
Really nothing? Is this package even still under maintenance? This is a serious issue
@kamami Last update few hours ago.
https://pub.dev/packages/permission_handler/changelog
@naderhezzy Great to see an update! But this issue is related to iOS
and the update seems only to fix the issue on Android
.
any progress here? I still got ERROR_ALREADY_REQUESTING_PERMISSIONS
Guys, for any location-related permission i suggest using Flutter Location Plugin and keep Permission Handler Plugin for other permissions. Good luck
@naderhezzy I tried Flutter Location Plugin but I cannot know if permission is locationalways
. It just let me know location permission is granted(there is granted limited but its about accuracy). Also, I cannot request location always. There's only location permission.
@naderhezzy I tried Flutter Location Plugin but I cannot know if permission is
locationalways
. It just let me know location permission is granted(there is granted limited but its about accuracy). Also, I cannot request location always. There's only location permission.
@choi-seung-min Then try geolocator: ^8.2.0. I hope this satisfy your needs
@naderhezzy thanks for recommending geolocator
but it's not working too. I ask for location while in use
before i ask location always
because my app use google map and it requires permission. After user grant location while in use
, geolocator
's requestPermission
does not ask for a new permission, but it returns location while in use
.
I'm having this error throw: ERROR_ALREADY_REQUESTING_PERMISSIONS every time try and request the permissions of the microphone. I have the correct podfile code as well! Been working on this for hours!
/*
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
class SimpleRecorder extends StatefulWidget {
@override
_SimpleRecorderState createState() => _SimpleRecorderState();
}
class _SimpleRecorderState extends State<SimpleRecorder> {
@override
void initState() {
openTheRecorder();
super.initState();
}
@override
void dispose() {
super.dispose();
}
Future<void> openTheRecorder() async {
var status = await Permission.microphone.request();
print(Permission.microphone.status.toString());
}
// ----
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: const Text('Simple Recorder'),
),
body: Container(),
);
}
}
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.calendar
# 'PERMISSION_EVENTS=0',
## dart: PermissionGroup.reminders
# 'PERMISSION_REMINDERS=0',
## dart: PermissionGroup.contacts
#'PERMISSION_CONTACTS=0',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=1',
## dart: PermissionGroup.speech
# 'PERMISSION_SPEECH_RECOGNIZER=0',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
#'PERMISSION_LOCATION=1',
## dart: PermissionGroup.notification
# 'PERMISSION_NOTIFICATIONS=1',
## dart: PermissionGroup.mediaLibrary
# 'PERMISSION_MEDIA_LIBRARY=0',
## dart: PermissionGroup.sensors
#'PERMISSION_SENSORS=0',
## dart: PermissionGroup.bluetooth
#'PERMISSION_BLUETOOTH=0',
## dart: PermissionGroup.appTrackingTransparency
#'PERMISSION_APP_TRACKING_TRANSPARENCY=0',
## dart: PermissionGroup.criticalAlerts
# 'PERMISSION_CRITICAL_ALERTS=0'
]
end
end
end
Error still happening in version permission_handler: ^10.2.0
Error still happening, are there any fixes planned? Edit: Fixed in latest versions of the package
I've reproduced it with location permissions indeed. I'll label it as a bug. However, I'm not sure if it is a bug from the plugin. Related to: https://github.com/Baseflow/flutter-permission-handler/issues/581
Kind regards,
Hi All, I did below changes and it worked for me can someone else confirm the same that it works for other as well or not.
Add below all of three permission in you info.plist file.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App Required Location Permission </string>
<key>NSLocationUsageDescription</key>
<string>App Required Location Permission</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App Required Location Permission</string>
Thank @DhavalRKansara
It finally works.