If I called the same function twice, on the second time Geolocation.GetLocationAsync() was invoked and it returned location. It looks like the timespan is not long enough. But even when I set it to 60 seconds, the first time it was still ignored. It is still the second time when it was invoked and returned the location. Don't know why. But as long as this works, it is still a solution.
Geolocation.GetLocationAsync() not working
I have this code:
var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10));
var currentLoc = await Geolocation.GetLocationAsync(request);
if (currentLoc?.Latitude != 0 && currentLoc?.Longitude != 0)
{
....
}
When execution reaches the second line, it skips it and also the rest of the code and jumps out of the entire function (the above is only part of a function). Location permission is already granted, and I didn't include it here. Anyone knows why this is happening? It is hard to debug because any exception catch branches are ignored, and no errors are thrown.