Primero, necesitas asegurarte de que has implementado el requerimiento de PermissionsPlugin.
En tu MainActivity, necesitas agregar el siguiente metodo.
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
Para que el Plugin de permissions funcione necesitas asegurarte que en tu metodo OnCreate
fijes el CurrentActivity. Eso se traduce en agregar la siguiente linea antes de LoadApplication(new App());
Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = this;
Finalmente, necesitas asegurarte de tomar en cuenta los permisos. Yo te recomendaria cambiar tu implemantacion de la siguiente manera.
public async Task RetriveLocation()
{
try
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
if (status != PermissionStatus.Granted)
{
if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
{
await DisplayAlert("Need location", "Gunna need that location", "OK");
}
var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
//Best practice to always check that the key exists
if (results.ContainsKey(Permission.Location))
status = results[Permission.Location];
}
if (status == PermissionStatus.Granted)
{
var position = await CrossGeolocator.Current.GetPositionAsync(TimeSpan.FromMilliseconds(10000));
txtLat.Text = "Latitude: " + position.Latitude;
txtLong.Text = "Longitude: " + position.Longitude;
}
else if (status != PermissionStatus.Unknown)
{
await DisplayAlert("Location Denied", "Can not continue, try again.", "OK");
}
}
catch (Exception ex)
{
txtLat.Text = "Error: " + ex;
txtLong.Text = "Error: " + ex;
}
}