Flutterlocation: Crash on iOS

Created on 3 Jan 2019  路  6Comments  路  Source: Lyokone/flutterlocation

I'm using this to get current user location which works perfectly fine in android but it crashes in iOS both in simulator and iPhone. It doesn't even go into the try catch clause. Both getLocation() and hasPermission() crashes with following errors in flutter:

* First throw call stack:
(
0 CoreFoundation 0x000000010bd201e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010b3bd031 objc_exception_throw + 48
2 CoreFoundation 0x000000010bd95975 +[NSException raise:format:] + 197
3 Runner 0x0000000102a17fe9 -[LocationPlugin initLocation] + 510
4 Runner 0x0000000102a18075 -[LocationPlugin handleMethodCall:result:] + 66
5 Flutter 0x000000010630f1ff __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 118

Thanks for helping.

All 6 comments

We have the same issue!

same issue

same issue

Same issue.

Hey ! with version 2.1 the plugin should be more reliable, please check it out :)

I figured out that my issue was totally due to my NOOBness. I was not correctly asking for the location permission in the AndroidManifest.xml nor in Info.plist. Figured it out while watching this YouTube video about implementing the permission_handler package.
https://www.youtube.com/watch?v=fNklvY1FEao&t=

Needed to add this to AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">

And to Info.plit

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs your location in order to function properly.</string> 
Was this page helpful?
0 / 5 - 0 ratings