Monday, 9 September 2019

CheckPermissionsAsync always returning Denied on Android

I'm using the Permissions Plugin to request fine location permission on Android; however, every time I call CheckPermissionsAsync, I get a response of Denied. Here's the code that I'm using:

protected override async void OnStart()
{
    PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.LocationWhenInUse);
    if (status == PermissionStatus.Unknown)
    {
        var result = await CrossPermissions.Current.RequestPermissionsAsync(Permission.LocationWhenInUse);
    }
}

This is running on the emulator and, to my knowledge, I haven't yet managed to execute the RequestPermissionsAsync call.

Is this expected behaviour? If so, how do I differentiate between Denied (not asked yet) and Denied (asked and refused)?

EDIT:

On further investigation, calling RequestPermissionsAsync doesn't seem to make any difference either way. My impression was that it would go to the native platform and display a "We need permissions.." dialogue box. Looking again at the samples a bit more for this plug-in, it almost seems like the answer is to just display the settings and let the user allocate whatever they feel; it feels a lot like I'm missing a key part of the puzzle here.



from CheckPermissionsAsync always returning Denied on Android

No comments:

Post a Comment