Flutter-geolocator: iOS doesn't ask for Location permissions

Created on 25 Jan 2019  ·  15Comments  ·  Source: Baseflow/flutter-geolocator

🐛 Bug Report


iOS simulator doesn't ask for the location permission. Seems like device just skip or 'hanging' with this. When I try to get geolocator.getCurrentPosition manually (by pressing button) it returns null. For Android all works as expected. I've checked location permission using geolocator.checkGeolocationPermissionStatus() and it's
GeolocationStatus.unknown.

Expected behavior

iOS simulator should ask for user permissions for the location service.

Reproduction steps

Configuration

Version: 2.1.1

Platform:

  • [12.1 ] :iphone: iOS

Most helpful comment

@dstuff @kika @JStuve @StephanCassel,
I fixed it! I was using on Info.plist this permission NSLocationAlwaysUsageDescription together with the NSLocationWhenInUseUsageDescription. But the app is set to target iOS 8, Flutter default. But NSLocationAlwaysUsageDescription should only be used with iOS 10+. This was messing up the permission prompt on the iOS app. I removed and it worked, asked the permission and I could get the location. I hope this can help you guys too.

All 15 comments

What I noticed is that when the app is first installed and accesses the location service the system pops up a dialog asking for permission and at the same time checkPermissionStatus() returns unknown. If user allows the access then the app may proceed to obtaining the Position.
There should be a way to wait for the user to either allow or deny the request.

I'm having the exact same issue. Android works fine but in iOS I've added NSLocationWhenInUseUsageDescription, however I never get prompted for permissions access so checkGeolocationPermissionsStatus() is always unknown. This is also on a physical device as well as the simulator.

Same problem for hours. Android works fine. iOS gave null.
I Removed the iOS app from the simulator and restarted. After that it works perfect. Puhhh.
I had some start problem due missing info in the podfile. It may caused the problem.

Same thing here. Removed app from device and simulator, reinstalled, same thing.
When try to get location the following exception appeared: ERROR_ALREADY_REQUESTING_PERMISSIONS

@dstuff @kika @JStuve @StephanCassel,
I fixed it! I was using on Info.plist this permission NSLocationAlwaysUsageDescription together with the NSLocationWhenInUseUsageDescription. But the app is set to target iOS 8, Flutter default. But NSLocationAlwaysUsageDescription should only be used with iOS 10+. This was messing up the permission prompt on the iOS app. I removed and it worked, asked the permission and I could get the location. I hope this can help you guys too.

@cetorres Finally got it! I made your recommended change, on top that I was also calling checkGeolocationPermissionStatus before getCurrentPosition so my permissions prompt was not triggering!

Thanks! :beers:

version: 3.0.0 ios also not prompt for permissions access.

From debugging in Xcode, it appears NSLocationAlwaysAndWhenInUseUsageDescription is also required. (Having only NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription fails silently in Flutter)

Same problem, everything said it proved, and nothing works. Not really sure how to solve it.

Thanks a ton @cetorres! I'm actually targeting iOS 10+ but I still had to remove NSLocationAlwaysUsageDescription to get it to work. My app doesn't need location info when not in use, so this is good enough.

Crazy! Apple approved my app for TestFlight with the usual...

You can now use this build for TestFlight testing or submit it to the App Store.

but also sent me this:

We identified one or more issues with a recent delivery for your app, [redacted] 1.0.0 (12). Your delivery was successful, but you may wish to correct the following issues in your next delivery:

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSLocationAlwaysUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

So looks like I'm still walking on a tight rope here. I can't upgrade the plugin because I don't want to cross the AndroidX hurdle right now...

What do you guys suggest? Just ignore the "we identified issues" message?

Update: Adding all the three below in info.plist worked for me. Apple is also happy.

NSLocationWhenInUseUsageDescription

NSLocationAlwaysAndWhenInUseUsageDescription

Thanks for the tip, @vejmartin

@kbrmimbyl You are a life-saver. I was missing the "NSLocationAlwaysAndWhenInUseUsageDescription" key in Info.plist and that was causing those problems!!

Intresting for anyone who has modified info.plist in AndroidStudio and not in XCode: For me it worked when I removed the "NSLocationAlwaysAndWhenInUseUsageDescription" and instead selected the corresponding "Privacy - Location Always and when in Use Usage Description" in Xcode. For some reason the others where allready formatted like that, but this one wasnt. I was encountering the same problems mentioned above, but onError it gave me nothing. The async was just awaiting and never proceeded. And then if you hotReload, you get the ERROR_ALREADY_REQUESTING_PERMISSIONS, because its still awaiting input to that permission request.
Targeting IOS11, on Android it worked all fine. Now it does on IOS as well.

I am having same issue with flutter web on IOS device.
application does not prompt any permission dialog on IOS, but it works on windows and android devices

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JunjaK picture JunjaK  ·  4Comments

prasant10050 picture prasant10050  ·  6Comments

dark-chocolate picture dark-chocolate  ·  3Comments

samo92 picture samo92  ·  6Comments

Sammius picture Sammius  ·  4Comments