Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCurrentPosition close app [iOS] #486

Closed
1 of 2 tasks
samo92 opened this issue Aug 19, 2020 · 6 comments
Closed
1 of 2 tasks

getCurrentPosition close app [iOS] #486

samo92 opened this issue Aug 19, 2020 · 6 comments
Labels
platform: ios Issue is related to the iOS platform type: bug Something isn't working
Milestone

Comments

@samo92
Copy link

samo92 commented Aug 19, 2020

馃悰 Bug Report

When i use getCurrentPosition the app closes,

Version: 5.3.2+2

Platform:

  • 馃摫 iOS
  • 馃 Android
@mvanbeusekom
Copy link
Member

Have you added the required configuration to your ios/Runner/Info.plist file (see the Permission section in the README.md)?

@mvanbeusekom mvanbeusekom added platform: ios Issue is related to the iOS platform status: needs more info We need more information before we can continue work on this issue. labels Aug 19, 2020
@samo92
Copy link
Author

samo92 commented Aug 19, 2020

Hello there, my info.plist has:

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.

in my app a FAB call a method like this:

getPos(){
try{
final resp = await mGeolocator.getCurrentPosition();
} catch (e) {
print(e.toString);
}
}

in android works perfectly, but in iOS never appears requestPermission and the app closes, debug console not print any exception.

@vijayanbits
Copy link

I am facing the same issue as well on my iOS Simulator. The app closes.
Working fine on an Android simulator and able to get the position.

My info.plist has:
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.

My Code:

void getLocation() async {

Position position = await Geolocator()
    .getCurrentPosition(desiredAccuracy: LocationAccuracy.low);

print(position);

}

@ChucNgo
Copy link

ChucNgo commented Aug 20, 2020

In your Targets -> Tab Signing&Capabilites -> Add Capability -> Select Background Modes
And choose options below.

image

@KennyChan94
Copy link

make sure your simulator has location enabled.
in your simulator -> Debug -> Location -> Custom Location...
image

@mvanbeusekom
Copy link
Member

@samo92, @vijayanbits during the weekend I published a release candidate for version 6.0.0 on pub.dev which solves a lot of problems specifically with permissions and reporting if the location services are not enabled.

I would very much appreciate it if you can give it a try and see if it solves this problem. Hope to hear from you.

@mvanbeusekom mvanbeusekom added this to the 6.0.0 milestone Aug 25, 2020
@mvanbeusekom mvanbeusekom added type: bug Something isn't working and removed status: needs more info We need more information before we can continue work on this issue. labels Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: ios Issue is related to the iOS platform type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants