Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestMicrophoneAuthorization callback procs at wrong time #306

Closed
jhiswin opened this issue May 25, 2018 · 3 comments
Closed

requestMicrophoneAuthorization callback procs at wrong time #306

jhiswin opened this issue May 25, 2018 · 3 comments
Labels
awaiting response If no response, issue will be closed

Comments

@jhiswin
Copy link

jhiswin commented May 25, 2018

I need to be able to react to when a user allows or denies authorization. Callback function when a request is made is not useful. Cannot find a way to do this without setting a background timer to continuously check permission status.

Added directly using cordova plugin add cordova.diagnostic.plugin

The callback is executing in parallel to the authorization request. Does not wait for user to "Allow" or "Deny" request.

cordova.plugins.diagnostic.requestMicrophoneAuthorization(function(status){
console.log(status);
});

status value is showing status before user presses a button

Also tried registerPermissionRequestCompleteHandler to no avail.

@jhiswin
Copy link
Author

jhiswin commented May 25, 2018

Found that you have to request the permission status again. The parameter given to the callback represents the status before user interaction.

@dpa99c
Copy link
Owner

dpa99c commented May 25, 2018

I've just investigated this and found that in the latest version of the plugin (v4.0.6), the success callback in being invoked correctly by requestMicrophoneAuthorization() only once the user has reponded to the runtime permissions dialog.

To reproduce my test case, please do the following:

  • Build and run the example project for Android
  • Use Chrome Developer Tools to inspect the app Webview and place a breakpoint on line 84 of index.js
  • Scroll down and press the "Request Microphone Authorization" button
  • Observe that the breakpoint in the success callback is not invoked until you respond to the native runtime permission dialog

FYI: while looking into this, I discovered a typo in the JS layer of the microphone module for Android:
it should define Diagnostic_Microphone.requestMicrophoneAuthorization, not Diagnostic.requestMicrophoneAuthorization.
This causes it to override the definition in the core module, but does not lead to the behaviour described in your issue.
I'll fix the typo in the next release of this plugin.

@dpa99c dpa99c added the awaiting response If no response, issue will be closed label May 27, 2018
@dpa99c
Copy link
Owner

dpa99c commented May 30, 2018

Closed due to no response

@dpa99c dpa99c closed this as completed May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response If no response, issue will be closed
Projects
None yet
Development

No branches or pull requests

2 participants