ARTICLE AD BOX
Quick context: The onPermissionRequest callback used for the Cordova Android WebView has some issues, which was already reported here. However, while that issue is not fixed, I'm trying to build a workaround for my project.
The workaround that I'm trying for it is to create a plugin to override the onPermissionRequest callback. I didn't find any official documentation on how to do that, but after some research and trial and error I managed to override it.
Here's a snippet of my plugin code:
// ... public class Permissions extends CordovaPlugin { // ... @Override public void onResume(boolean multitasking) { this.cordova.getActivity().runOnUiThread(() -> { Log.w(TAG, "trying to override"); SystemWebView wv = (SystemWebView)this.webView.getView(); wv.setWebChromeClient(new SystemWebChromeClient((SystemWebViewEngine)this.webView.getEngine()) { @Override public void onPermissionRequest(final PermissionRequest request) { // Implementation... } }); }); } // ... }The issue is that it's unreliable. It seems that Cordova can randomly decide to override my own callback with their default callback. So my override will work for a while until it doesn't.
So my question is if there's any way to reliably override the default onPermissionRequest callback, or if there's any other way I can avoid using the default onPermissionRequest callback because of its current issues.
