question

EJ-5254 avatar image
0 Votes"
EJ-5254 asked WenyanZhang-MSFT edited

Xamarin Forms Geolocation.GetLocationAsync on iOS hangs and never returns?

Hi,

Trying to implement location tracking in our app:

var request = new GeolocationRequest( GeolocationAccuracy.Medium, TimeSpan.FromSeconds( 10 ) );
Location location = await Geolocation.GetLocationAsync( request );

Above works on Android, but hangs in iOS and never returns in GetLocationAsync line. Testing on iPhone 13 Pro, location is enabled and permission is given to the app. Also have following keys in Info.plist file:

 <key>UIBackgroundModes</key>
 <array>
     <string>location</string>
 </array>
 <key>NSLocationWhenInUseUsageDescription</key>
 <string>Jim2 app needs access to location for Location tracking</string>
 <key>NSLocationAlwaysUsageDescription</key>
 <string>Jim2 app needs access to location while in background.</string>
 <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
 <string>Jim2 app needs access to location for Location tracking</string>

Any ideas?

dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @EJ-5254 , I'm not sure if you are testing the location in background mode. You mean the location will never have a value, or it gets the value once then it never returns? And would you mind sharing the Essentials version and your iOS version? I test on iOS 15.4 iPhone13 device, I have to say, I can't reproduce your issue. Would you mind sharing more information?
If you want to get the location in background mode, see: https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-walkthroughs/location-walkthrough

0 Votes 0 ·

0 Answers