Just released my latest plugin to request permissions from shared code! Checkout my blog for details
Code: https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Permissions
NuGet: http://www.nuget.org/packages/Plugin.Permissions
Example:
try
{
var status = await CrossPermissions.Current.CheckPermissionStatus(Permission.Location);
if (status != PermissionStatus.Granted)
{
if(await CrossPermissions.Current.ShouldShowRequestPermissionRationale(Permission.Location))
{
await DisplayAlert("Need location", "Gunna need that location", "OK");
}
var results = await CrossPermissions.Current.RequestPermissions(new[] {Permission.Location});
status = results[Permission.Location];
}
if (status == PermissionStatus.Granted)
{
var results = await CrossGeolocator.Current.GetPositionAsync(10000);
LabelGeolocation.Text = "Lat: " + results.Latitude + " Long: " + results.Longitude;
}
else if(status != PermissionStatus.Unknown)
{
await DisplayAlert("Location Denied", "Can not continue, try again.", "OK");
}
}
catch (Exception ex)
{
LabelGeolocation.Text = "Error: " + ex;
}