Comments (4)
Ps.
You need all 4:
NSLocationUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationWhenInUseUsageDescription
Only after running the app directly in xcode did the message appear that stated there are missing permissions in the info.plist
from flutter-permission-plugins.
@rahulgs12 this exception explains that you have an active request for permissions when a second call to the requestPermissions
is coming in. Make sure you await the call to requestPermissions
(which you indicate you do) and that you call it only once.
A common mistake is that people call the requestPermissions
method from build
method in there widget. In some situations this method can be called multiple times by Flutter to organize the UI and in this case also calling the plug-in multiple times.
If you keep on having problems please feel free to send us a code example, even better would be a small app that shows how to reproduce the error and we will be glad to have a look at it.
from flutter-permission-plugins.
Hello @mvanbeusekom
Thank you for your response. Please, anyone, I need help with this simple geolocation app. It is very simple but I'm having the same problem in ios. It's Working in Android.
dependencies:
location: ^2.3.5
provider: ^3.0.0+1
geolocator: ^5.1.1+1
info.plist file
NSLocationAlwaysUsageDescription
This app needs access to location when in the background.
NSLocationAlwaysAndWhenInUseUsageDescription
This app needs access to location when open and in the background.
==============
main.dart file
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Get User Location',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Get User Location'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@OverRide
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
Position position = null;
void requestLocationPermission(BuildContext context) async {
Position currentPosition = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
setState(() {
position = currentPosition;
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Requesting Location Permission'),
),
body:Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Center(
child: new Text(
"Requesting Location Permission...",
textAlign: TextAlign.center
),
)
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: RaisedButton(
onPressed: () {
requestLocationPermission(context);
},
child: Text('Get Location Permission'),
color: Colors.green
),
),
Center(
child: Text(position.toString()),
)
]
),
);
}
}
=======
Debug window:
Syncing files to device iPhone 6s...
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSION, A request for permissions is already running, please wait for it to finish before doing another request., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
#2 LocationPermissions.requestPermissions (package:location_permissions/src/location_permissions.dart:70:45)
#3 Geolocator._getLocationPermission (package:geolocator/geolocator.dart:195:12)
#4 Geolocator.getCurrentPosition (package:geolocator/geolocator.dart:91:47)
#5 _MyHomePageState.requestLocationPermission (package:flutterlocationmap/main.dart:34:51)
#6 _MyHomePageState.build. (package:flutterlocationmap/ma<…>
Conclusion:
It doesn't return the longitude and latitude. Frozen.
from flutter-permission-plugins.
Sorry, I was missing these: it works
NSLocationWhenInUseUsageDescription
This app needs access to location when open.
NSLocationAlwaysUsageDescription
This app needs access to location when in the background.
NSLocationAlwaysAndWhenInUseUsageDescription
This app needs access to location when open and in the background.
from flutter-permission-plugins.
Related Issues (20)
- Multiple bugs when we deny location permission and then ask for it again HOT 1
- iOS - Location permission dialog is not appearing and always giving denied response. HOT 9
- Is there any plans to support Web version? HOT 1
- Location permission level has no effect on checking or requesting permissions. HOT 3
- AndroidManifest need ACCESS_FINE_LOCATION permission? HOT 2
- Request ServiceStatus
- On iOS 13, location always is incorrectly returned as granted when you only have when in use HOT 2
- Method requestPermissions returns inconsistent results with "Allow Once" on iOS
- Android 11 support problem
- Android permission allowWhenAppInUse triggering inactive and resumed appLifeStateEvent
- [iOS] Requesting location always permissions does not return status when requesting more than once or selecting while using HOT 4
- Issue with the checkPermissionStatus on Android when the user selects "Allow only while using the app" HOT 2
- iOS permission key search is incomplete HOT 1
- [android] "Can request only one set of permissions at a time." HOT 5
- Null Safety Support HOT 1
- Will these packages eventually replace the permission_handler package? HOT 1
- Open turn on location service
- Show Rationale Dialog
- On Android version less than 6 (M) checkPermissionStatus returns Denied HOT 4
- LocationPermissionsPlugin.java uses or overrides a deprecated API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-permission-plugins.