Git Product home page Git Product logo

Comments (4)

Theunodb avatar Theunodb commented on June 22, 2024 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.

mvanbeusekom avatar mvanbeusekom commented on June 22, 2024

@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.

Viktoru avatar Viktoru commented on June 22, 2024

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.

Viktoru avatar Viktoru commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.