jamesmontemagno / PermissionsPlugin

Check and Request Permissions Plugin for Xamarin and Windows
MIT License
282 stars 85 forks source link

[BUG] RequestPermissionAsync<>() in XCode12/IOS14 not returning any value. #185

Open SteveGrixti-Remax opened 3 years ago

SteveGrixti-Remax commented 3 years ago

Bug Information

Version Number of Plugin: 6.0.1 Device Tested On: N/A Simulator Tested On: iPhone 11 Pro Max iOS 14.0 Simulator (Mac) Version of VS: 8.7.8 Version of Xamarin: 4.8.0.1534

Steps to reproduce the Behavior

  1. Check if the app has access to the users location/storage etc..
  2. If permission is not granted, request permission from user.

Expected Behavior

  1. The user give permissions for the app to access the requested resource.
  2. The app continues as neccessary.

Actual Behavior

  1. The user give permissions for the app to access the requested resource.
  2. The app receives no response from the method RequestPermissionAsync and so the encapsulated method cannot continue.

Code snippet

public LoadingPage() {
  InitializeComponent();
}

protected override async void OnAppearing() {
  base.OnAppearing();

  bool permissionsGranted = await CheckAndRequestPermissions();

  if (permissionsGranted) {
    //Continue
  }
}

public async Task<bool> CheckAndRequestPermissions() {
  List<string> permissionsNotGranted = new List<string> ();

  PermissionStatus locationStatus = await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission> ();

  if (locationStatus != PermissionStatus.Granted) {
    PermissionStatus requestLocationPermission = await CrossPermissions.Current.RequestPermissionAsync<LocationPermission> ();

    if (requestLocationPermission.HasFlag(PermissionStatus.Denied)) permissionsNotGranted.Add("location");
  }

  PermissionStatus storageReadStatus = await CrossPermissions.Current.CheckPermissionStatusAsync<StoragePermission> ();

  if (storageReadStatus != PermissionStatus.Granted) {
    PermissionStatus requestStoragePermission = await CrossPermissions.Current.RequestPermissionAsync<StoragePermission> ();

    if (requestStoragePermission.HasFlag(PermissionStatus.Denied)) permissionsNotGranted.Add("storage");
  }

  return permissionsNotGranted.Count() == 0;
}

Note

SangI762 commented 3 years ago

Have the same issue. Works on iOS 14.2 beta and iOS 13.7, but doesn't work on ios 14.0.1 Any time frame when it could be fixed?

SteveGrixti-Remax commented 3 years ago

I am bumping this issue as it is quite a showstopper for us. Any news?

EmmanVazz commented 3 years ago

This issue is fixed in Xamarin Essentials preview. https://github.com/xamarin/Essentials/issues/1390

chrisfoulds commented 3 years ago

i moved to the latest beta of essentials which fixes this - was a 15-20 min effort and can confirm it works on 13.x and 14.x

sisaacks commented 3 years ago

Hello....I am still having this issue on IOS 14 with Iphone 11. I have updated to the latest Xamarin, IOS, and VS

Lelelo1 commented 3 years ago

Hello....I am still having this issue on IOS 14 with Iphone 11. I have updated to the latest Xamarin, IOS, and VS

Same