Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

UWP: RequestPermissionAsync(Location) always returns PermissionStatus.Granted #162

Open
landre14 opened this issue Jan 3, 2020 · 0 comments

Comments

@landre14
Copy link

landre14 commented Jan 3, 2020

Bug Information

Version Number of Plugin: 3.0.0.12
Device Tested On: Windows 10 Dell Laptop, Panasonic Toughpad Windows 10
Simulator Tested On: N/A
Version of VS: 16.3.2
Version of Xamarin.Forms: 4.3.0.991211

Versions of other things you are using:
Plugin.CurrentActivity v2.1.0.4
Xam.Plugin.Geolocator v.4.5.0.6
Xamarin.Forms.Maps v.4.1.0.618606

Steps to reproduce the Behavior

Call CrossPermissions.Current.RequestPermissionAsync(Permission.Location) anywhere in the shared project.

Expected Behavior

Should return the <Permission,PermissionStatus> and re-prompt the user to grant/deny the permission.

Actual Behavior

UWP only: If using RequestPermissionAsync(Permission.Location), the call will always return a PermissionStatus.Granted even when the user has already denied the permissions. The user will NOT be re-prompted to grant/deny location permissions.

Code snippet

From the Plugin Permissions.UWP.cs code:
image

Per the above screenshot, it appears the UWP implementation of RequestPermissionAsync() is going to always return PermissionStatus.Granted.

How we are using this:
` public async Task CheckandRequestDevicePermission(PermissionType XAMpermissionType)
{
var XAMpermissionStatus = await CheckPermissionStatusAsync(XAMpermissionType);

        if (XAMpermissionStatus != CurrentPermissionStatus.Granted)
        {
            var grantResults = await _pluginPermission.RequestPermissionsAsync(new Plugin.Permissions.Abstractions.Permission[] { PermissionTypeConverter(XAMpermissionType) });
            foreach (var item in grantResults.Keys)
                if (grantResults[item] != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
                {
                    return false;
                }
        }
        return true;
    }`
@landre14 landre14 changed the title UWP: RequestPermissionAsync(Location) always returns "Granted" UWP: RequestPermissionAsync(Location) always returns PermissionStatus.Granted Jan 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant