-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
When used with firebase/facebook/onesignal plugins JS code injection not working #189
Comments
The error
is about JavaScript and not coming from Dart/Flutter or any of flutter plugins because plugins such as flutterfire or flutter_facebook_login, don't interact in any way with the Probably you have some bugged javascript code in some scripts (not this one because there isn't a Also, in the onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
print("""
console output:
sourceURL: ${consoleMessage.sourceURL}
lineNumber: ${consoleMessage.lineNumber}
message: ${consoleMessage.message}
""");
}, If you want, you can use the 2.0 version of this plugin because it has shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
print("AJAX REQUEST: ${ajaxRequest.method} - ${ajaxRequest.url}, DATA: ${ajaxRequest.data}");
// Manipulates the ajax request
// ...
return ajaxRequest;
},
onAjaxReadyStateChange: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
print("AJAX READY STATE CHANGE: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.status}, ${ajaxRequest.readyState}, ${ajaxRequest.responseType}, ${ajaxRequest.responseText}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED;
},
onAjaxProgress: (InAppWebViewController controller, AjaxRequest ajaxRequest) async {
print("AJAX EVENT: ${ajaxRequest.method} - ${ajaxRequest.url}, ${ajaxRequest.event.type}, LOADED: ${ajaxRequest.event.loaded}, ${ajaxRequest.responseHeaders}");
return AjaxRequestAction.PROCEED;
}, To use this event, you need to set NOTE that version 2.0 it is not published officially yet and the syntax changes a little bit! However, you can point the dependency on the master branch of this repository (see https://flutter.dev/docs/development/packages-and-plugins/using-packages#dependencies-on-unpublished-packages). |
Thank for you quick response @pichillilorenzo getting following error if I use the ajaxinterceptor with v2.0. I know this is an error because some ajax requests are using a responseType json. Can you please help? |
Ok! I will fix it as soon as possible. |
Thanks a lot for your quick response @pichillilorenzo. For one website I am getting the following error as well. I need an AJAX interceptor for that website which I need for our application (we want to move that app to production as early as possible. we are only stucked with AJAX interceptor).
I would really appreciate your help if you will solve this issue as well, Regards |
… No need to listen to window.addEventListener(flutterInAppBrowserPlatformReady, fuction(){ }) javascript event anymore to use JaaScript message handlers
Instead, about the error of the Content Security Policy, I think the unique available solution could be something like this: https://stackoverflow.com/a/34777722/4637638. If you need to call specific javascript code but you get the Content Security Policy error, the only way is something like this: onLoadStop: (InAppWebViewController controller, String url) async {
controller.loadUrl(url: "javascript:(function() { console.log('this code can run'); })();");
}, So, you must put all the javascript code that you need to run in one line. About the last commit, in case you are using
|
Hello @pichillilorenzo Fortunately, it is solving the issue with responseType json, text etc.
If I use your ajaxInterceptor then some part of the page not even loading so I am trying to apply my simple AjaxInterceptor with the above code after resource is loaded. |
@vijayawoshe my javascript ajax interceptor should be fixed in the latest commit now! Also I re-added the |
@pichillilorenzo Thanks for your quick response. I will check and let you know. I really appreciate. |
The plugin is super awesome but here is an inexplicable problem that is bugging us.
We are using this flutter webview plugin in Android. We inject the following JavaScript code to intercept AJAX network call. It is working fine with most of the plugins we are using in our app and intercepting network call as expected. But as soon as we integrate/build our app with certian other plugins (any of: firebase/facebook/onesignal plugins) it stops intercepting the AJAX call and we get the following error.
We load the JS code like this:
The example JS code that was injected above:
When we build with any of the following flutter plugins the above failure/error happens.
What can go wrong with the above plugins that
inappbrowser
fails to work as expected?The text was updated successfully, but these errors were encountered: