prerak desai
prerak desai

Reputation: 171

in xamarin.android not asking for permission in visual studio 2017?

in xamarin.android not asking for permission when, in properties of xamarin.android in android manifeast file android tranget version is :Use Compile using SDK Version. this option is coming in visual studio 2017 but not coming in visual studio 2019. so problem coming in appstore wirch not approve the app for this type of thing

Upvotes: 2

Views: 125

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

You can use the Plugin.Permission from nuget .

Usage

For example you need to request the permission of location

var status = await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission>();
if (status != PermissionStatus.Granted)
{
    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
    {
        await DisplayAlert("Need location", "Gunna need that location", "OK");
    }

    status = await CrossPermissions.Current.RequestPermissionAsync<LocationPermission>();
}

if (status == PermissionStatus.Granted)
{
    //Query permission
}
else if (status != PermissionStatus.Unknown)
{
    //location denied
}

For more details you can check the Docs .

Upvotes: 1

Related Questions