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

PhotoPermission always starts at 'unknown' and is therefore never requested #142

Open
csteeg opened this issue Jun 6, 2019 · 5 comments

Comments

@csteeg
Copy link

csteeg commented Jun 6, 2019

Bug Information

Version Number of Plugin: 5.0-beta
Device Tested On: iPhone/iPad (both iOS 12)
Version of Xamarin: 4.0

Steps to reproduce the Behavior

Try to request Photos permissions on ios:

cameraStatus = await CrossPermissions.Current.RequestPermissionAsync<PhotosPermission>().ConfigureAwait(false);

It will return unknown always.
Also, checking it returns unknown always:

await CrossPermissions.Current.CheckPermissionStatusAsync<PhotosPermission>().ConfigureAwait(false)

This is because https://github.com/jamesmontemagno/PermissionsPlugin/blob/master/src/Plugin.Permissions/Permissions.ios.cs#L413 checks for unknown in RequestPhotosPermission() and then returns unknown without trying a request.

I created my own 'ForceRequestPhotosPermission' in my ios project, with the same code as in Permissions.ios.cs RequestPhotosPermission() but without the check for unknown. Everything works like a charm then. After approve or deny, the status is never unknown again

@NickeManarin
Copy link

NickeManarin commented Jun 13, 2019

The same can be said about the Camera permission.

Version Number of Plugin: 3.0.0.12
Device Tested On: Android Pie on emulator.
Version of Xamarin: 4.0

Edit: I forgot to put this line in my activity, to get the result:

Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);

And this line in the AssemblyInfo.cs:

[assembly: UsesPermission(Android.Manifest.Permission.Camera)]

It's working normally now.

@jamesmontemagno
Copy link
Owner

This says if it is Unknown (which is the default) then request it. That code works as expected from all of my tests.....

@csteeg
Copy link
Author

csteeg commented Jun 14, 2019

My bad, I read the Permissions.ios.cs line 413 too fast I guess. It checks for != unknown
Very strange though that it doesn't work when using your library call for this in my project, but when I remove the check for unknown, and just request it, it works :(

@jamesmontemagno
Copy link
Owner

I'll give it another quick debug through and check.

@jveltd
Copy link

jveltd commented Jun 1, 2020

We are seeing this issue as well.

Everything has been working well for the last 6-months+ however after updating to the latest nugets for XF, Permissions, MediaPlugin etc the permissions are no longer working.

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

4 participants