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

RequestPermissionsAsync never returns when permission is requested #94

Closed
Devvox93 opened this issue Apr 23, 2018 · 9 comments
Closed

Comments

@Devvox93
Copy link

Devvox93 commented Apr 23, 2018

return await tcs.Task.ConfigureAwait(false);

I get an exception on this line if a permission needs to be requested.
The specific exception is "Task got cancelled".

After either denying or allowing the permission prompt, further code after the call to this method is not executed and therefore I cannot check the result of the requested permission.

As workaround I now directly call ActivityCompat.RequestPermissions with a fixed string "android.permission.CAMERA" as that is the one I need at the moment.
However I would like to use this plugin if it works as intended.

UPDATE: This issue is very similar to what's described in #85

Another UPDATE: Turns out I had the OnRequestPermissionsResult in the wrong file.
I now manually re-check the permissions in this method after they are requested.
It would still be nice if the method would actually return its return type
Task<Dictionary<Permission, PermissionStatus>>
Therefore I leave this issue open.

@rizamarhaban
Copy link

try my work around here: #93 (comment)

@Devvox93
Copy link
Author

Thanks @rizamarhaban. I have a different workaround, like described in the 2nd update. It works, but the possibility of crashes seems enough reason to let the author look into this in more detail and come with a solid solution.

@jamesmontemagno
Copy link
Owner

Closing as it was missconfigured

@Devvox93
Copy link
Author

@jamesmontemagno It was, but the fact still is that that method does not return its return type in all cases (like when permissions are requested).
Therefore the task stays open and on moving to another view/fragment the task is cancelled by a dispose, which causes the crash.

Saying "misconfigured" is the easy fix. Oh wait, it isn't a fix...
Anyway, it's your library bro. No hard feelings as I've worked around this bug.

@jamesmontemagno
Copy link
Owner

If you create a small reproduction of the issue that would help. I have not had any issues like this at all in my apps, so actually seeing the issue is important to fix it.

@Devvox93
Copy link
Author

You're right. I'll post that tomorrow.

@jamesmontemagno
Copy link
Owner

Can you post that with a new clean issue as well :)

@Devvox93
Copy link
Author

Will do!

@Devvox93
Copy link
Author

@jamesmontemagno A day delay, but the new issue is #95

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

3 participants