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

shouldInterceptAjaxRequest no call #344

Closed
leielyq opened this issue May 13, 2020 · 11 comments
Closed

shouldInterceptAjaxRequest no call #344

leielyq opened this issue May 13, 2020 · 11 comments
Labels

Comments

@leielyq
Copy link

leielyq commented May 13, 2020

initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
debuggingEnabled: true,
javaScriptCanOpenWindowsAutomatically: true,
useShouldInterceptAjaxRequest: true,
useShouldInterceptFetchRequest: true,

                )
            ),

            shouldInterceptAjaxRequest: (InAppWebViewController controller, AjaxRequest ajaxReq) async {
              print("ajaxReq.url: ${ajaxReq.url}");

              ajaxReq.headers.setRequestHeader("token", DeviceManager.getDeviceToken());
              ajaxReq.headers.setRequestHeader("deviceid", DeviceManager.getDeviceId());

              return ajaxReq;
            },
@pichillilorenzo
Copy link
Owner

I don't have enough information about your problem. I need a more detailed description.

An ajax example is available inside the example/test_driver folder: https://github.com/pichillilorenzo/flutter_inappwebview/blob/master/example/test_driver/in_app_webview_ajax_test.dart

The corresponding server-side (Node.js) that manages the ajax request is here:

app.post("/test-ajax-post", (req, res) => {

@leielyq
Copy link
Author

leielyq commented May 26, 2020

This problem appears on Android phones

@pichillilorenzo
Copy link
Owner

pichillilorenzo commented May 26, 2020

Did you get some javascript errors from debugging (chrome://inspect/#devices)??

However, without any code to test, I can do nothing about it, because I can't reproduce your error.
As I said, the ajax example I linked to you is working.

If the ajax request you are trying to intercept has been made before the onLoadStop event (that is the onPageFinished event on Android platform), then, on Android, there isn't anyway to intercept it unfortunately!

If you can control the javascript code of the webpage your showing, then the ajax request should be made after the DOM is ready, otherwise you can't intercept it.

@leielyq
Copy link
Author

leielyq commented May 27, 2020

@pichillilorenzo Thanks, indeed as you said at the end

@leielyq leielyq closed this as completed May 27, 2020
@leielyq
Copy link
Author

leielyq commented Jun 11, 2020

@pichillilorenzo hi,I have a problem again, sometimes it won't be called on the Android device. The URL is https://h5.jimmychat.com/active/#/pages/index/index, very sad, please help me.

@leielyq leielyq reopened this Jun 11, 2020
@pichillilorenzo
Copy link
Owner

Could you explain to me where are your Ajax calls in your code? Otherwise, I can't tell if it is working or not. What do you expect exactly in your use case?

@leielyq
Copy link
Author

leielyq commented Jun 12, 2020

@pichillilorenzo in init(), call https://tchatweb.jimmychat.com/TChat/user/score/info,This ajax needs to set a specific request header, so I need to use the shouldInterceptAjaxRequest method to forward. Mainly, it is normally available on iOS devices.Oh hope you can understand what i'm talking about

This was referenced Jul 6, 2020
@leielyq
Copy link
Author

leielyq commented Oct 30, 2020

@pichillilorenzo I finally found out that it cannot be called in China. Is it because part of the network is blocked, like the Chinese network cannot access google.com

@leielyq
Copy link
Author

leielyq commented Oct 30, 2020

Is there any Google service in flutter_inappwebview's js code that intercepts Ajax?

Copy link

github-actions bot commented Oct 7, 2024

This issue is stale and has been automatically closed because it has been open for more than 365 days with no activity. Please reopen a new issue if you still have it.

@github-actions github-actions bot added the stale label Oct 7, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants