pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.27k stars 1.61k forks source link

How do I set Referer because I need to add Referer when wechat Pay #1558

Closed 2971026328 closed 1 month ago

2971026328 commented 1 year ago

I would like to implement setting referer, similar to the link below for other plugins, but I can't find it in this version, so if anyone implements this, please help me fix this problem, thanks https://www.jianshu.com/p/cd02cfab39f8/ I used flutter_inappwebview: ^6.0.0-beta.22 this version

I have tried the following picture but it doesn't work. Is it my fault c7ed90e8ebe9ec2545944c486989a0f dca9258a42b17723610f024f50c3827

github-actions[bot] commented 1 year ago

👋 @2971026328

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

saixin commented 1 year ago

any update?

2971026328 commented 1 year ago

I have used the latest version :flutter_inappwebview: ^6.0.0-beta.22 , but the problem still exists. Could you help me solve this problem? Thank you very much

xuixnwei commented 1 year ago

@ @2971026328 how did you finished this question? i got the same question now

xuixnwei commented 1 year ago

@2971026328 i get it!!!

shouldOverrideUrlLoading: (controller, navigationAction) async { var uri = navigationAction.request.url!; navigationAction.request.headers = { "Referer":referer }; controller.loadUrl(urlRequest: navigationAction.request); referer = uri.toString(); String url = uri.toString(); if (url.startsWith("weixin://") || url.startsWith("alipays://") || url.startsWith("alipay://")) { controller.stopLoading(); await launchUrl(uri); Future.delayed(const Duration(milliseconds: 500), () { navigationAction.request.url = Uri.parse(cloudUrl); controller.loadUrl(urlRequest: navigationAction.request); }); return NavigationActionPolicy.CANCEL; } return NavigationActionPolicy.ALLOW; },

github-actions[bot] commented 1 month ago

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[bot] commented 2 weeks ago

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.