flutter - 如何启用 webview cookie?
问题描述
我正在尝试使用 webview 在我的颤振应用程序中实现名为“cow pay”的支付网关,但我总是收到此错误。这是我的代码:
WebView(
initialUrl:
"my url",
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
javascriptChannels: <JavascriptChannel>{
_toasterJavascriptChannel(context),
},
onPageStarted: (String url) {
print('Page started loading: $url');
},
onPageFinished: (String url) {
print('Page finished loading: $url');
},
gestureNavigationEnabled: true,
)
解决方案
尝试删除initialUrl: "my url",
另外,使用webview_cookie_manager插件
WebView(
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) async{
_controller = webViewController;
await cookieManager.setCookies([
Cookie(cookieName, cookieValue)
..domain = domain
..expires = DateTime.now().add(Duration(days: 1))
..httpOnly = false
]);
_controller.loadUrl("your URL");
},
)
推荐阅读
- azure - 标记为未定义的 Azure Pipeline Secret 环境变量
- python - 需要带有请求的 cookie 的网页抓取页面
- c# - BackgroundWorker 仅在完成时报告进度
- firebase - Cloud_Firestore 包颤振/没有调试控制台错误
- python - 为什么 itertools.cycle() 函数使用最大内存?
- angular - 等待 Observable 完成
- ruby - 如何使用 webmock gem 在 Ruby 中模拟 POST 请求?
- unit-testing - 如何对使用 ACL 控件的 Hyperledger Fabric Go 链码执行单元测试?
- python - 递归函数返回 None 而不是字符串值
- javascript - 序列不包含元素?无法处理错误?