Closed tibbsa closed 1 month ago
This should be resolved in plugin v7.2.0 which was just published.
This changes getCameraAuthorizationStatus()
to natively derive the single combined status result based upon build SDK version and requested permission statuses.
It also adds getCameraAuthorizationStatuses()
to return the individual statuses of requested permissions related to camera, so you can interpret and combine the logic of these permission results yourself.
Bug report
[X] I have read the issue reporting guidelines
[X] I confirm this is a suspected bug or issue that will affect other users
[X] I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
[X] I have read the documentation thoroughly and it does not help solve my issue.
[X] I have checked that no similar issues (open or closed) already exist.
Current behavior:
If an application tries to check the status of camera permissions, or request camera permissions, while also requesting media access permissions at the same time, the return value is ambiguous. The callback accepts only a single 'status' value, but three different permissions are being sought for. It is entirely possible for a user to agree to allowing camera access, but then deny access to media read/write. In that case, the 'status' value in the callback is DENIED, even though the user did in fact grant camera access.
Expected behavior:
If both camera and storage permissions are being requested together, the callback value should delineate the result of each permission request. Since this in and of itself would be a breaking change for existing applications, it may be more sensible to separate this into two separate permissions check/request functions instead of combining camera and media access together.
Steps to reproduce:
More information on how I came to this conclusion is below, but this behaviour is obvious and reproduced in the example project as well. Grant access to the camera but not media, and the status display still shows the camera as being not authorized.
cordova.plugins.diagnostic.getCameraAuthorizationStatus()
. As expected, it returns NOT_REQUESTED.cordova.plugins.diagnostic.requestCameraAuthorization
(with 'external storage' = false). This pops up the camera permission dialog. I say "allow while using the app".adb
logs, I can see that this appears to work. Below is an extract of what I think are the relevant log entries:It seems that Cordova Diagnostics seems that CAMERA permission was GRANTED, and yet when the result is returned to my app it has changed to DENIED_ALWAYS.
Adding some diagnostic logging to the Cordova diagnostics plugin,
getCameraAuthorizationStatus
is receiving this back from `Diagnostic.instance._getPermissionsAuthorizationStatus()":But then somewhere between receiving that and handing off the
JSONObject
tocallbackContext.success(statuses)
, we lose the fact that there are in fact 3 different permissions being returned, and somehow my callback is only gettingDENIED_ALWAYS
even thoughCAMERA
was granted.I traced
callbackContext.success()
through to a call to Cordova Webview’ssendPluginResult()
but I do not know how that is implemented. It seems to be ‘losing’ the additional information there, though.Environment information
Quasar 2.16.9, Cordova 12.0.0, Cordova-Android 13.0.0, Cordova-IOS 7.1.1, Cordova Plugin Diagnostic 7.1.4.
Runtime issue
Related code:
From the example project:
Console output
n/a
Other information:
n/a