Reputation: 330
I am using the Geolocator plugin version 6.1.7.
When I try to request the current location, my app abruptly closes without any exception.
Debug Console says Lost connection to device. Exited (sigterm)
This only happens on iOS (physical device and simulator). This function runs fine on the android simulator as well as a physical device.
Here's the code:
Future<bool> getLocation(bool refresh) async {
position = await Geolocator.getCurrentPosition();
if (mapPosition == null || refresh) {
mapPosition = position;
}
return true;
}
Crashes at the getCurrentPosition()
function.
I have added the required permissions in the Info.plist file.
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required to show you relevant meals in your area.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location is required to show you relevant meals in your area.</string>
Is there something I'm missing?
Edit:
I have made sure that the app has permission granted. The location's permission level is 'While Using the App' in the Settings. Also made sure my location is on in the Settings.
Upvotes: 1
Views: 3532
Reputation: 220
I had a similar issue but I was able to resolve it by adding background mode permission to my info.plist file, just like this.
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
Upvotes: 0
Reputation: 330
Answering my own question here.
I explored the Info.plist to find any abnormalities and noticed that there was an item for Background Location updates.
<key>EnableBackgroundLocationUpdates</key> <true/>
I got rid of this line and the crashing problem went away.
Hope this helps anyone else that experiences something similar.
Upvotes: 1