i'm trying to get lat and long using Xamarin.Essentials package but i'm getting an exception says"exception: this functionality is not implemented in the portable version of this assembly. you should reference the nuget package from your main application project in order to reference the platform-specific implementation. at xamarin.essentials.geolocation.platformlocationasync"
i installed the package to every platform
here's my code:
private async void Button_Clicked(object sender, EventArgs e)
{
try
{
var request = new GeolocationRequest(GeolocationAccuracy.Medium);
var location = await Geolocation.GetLocationAsync(request);
if (location != null)
{
latitude.Text = location.Latitude.ToString();
longitude.Text = location.Longitude.ToString();
}
}
catch (FeatureNotEnabledException fnex)
{
}
catch (PermissionException perex)
{
}
catch (Exception ex)
{
await DisplayAlert("Error3", ex.ToString(), "ok");
}
}