webview 监听及获取cookie
https://www.cnblogs.com/pjl43/p/9866753.html
https://www.jianshu.com/p/55092eb06c17
requests:
https://stackoverflow.com/questions/53101858/handling-cookies-in-flutter
heck out requests, a flutter library to help with modern RESTful http requests (basic cookies support and json)
- as of now, it uses shared_preferences which is not the best practice (security-wise) to store sensitive data (session-ids etc) Issue #1
pubspec.yaml
dependencies:
requests: ^1.0.0
Usage:
import 'package:requests/requests.dart'; // ... // this will persist cookies
await Requests.post("https://example.com/api/v1/login", body: {"username":"...", "password":"..."} ); // this will re-use the persisted cookies
dynamic data = await Requests.get("https://example.com/api/v1/stuff", json: true);
https://pub.dartlang.org/packages/dio#cookie-manager
https://github.com/fluttercommunity/flutter_webview_plugin/pull/51
Unfortunately, I was not considering operating LocalStorage from outside WebView.
Although I tried a little investigation,
there seems to be a case in which execution of evalJavascript or access to LocalStorage can not be performed normally due to the timing of WebView startup, the timing of page loading, and so on.
You may be able to avoid it by waiting until the first page loading is completed and then accessing LocalStorage with evalJavascript.
like this.
// On urlChanged stream
StreamSubscription<WebViewStateChanged> _onStateChanged;
_onStateChanged = flutterWebviewPlugin.onStateChanged.listen((WebViewStateChanged state) {
if (mounted) {
if (state.type == WebViewState.finishLoad) {
flutterWebviewPlugin.evalJavascript(
"window.localStorage.setItem('LOCAL_STORAGE','SOMETOKEN');" +
"document.getElementById('showLocalStorageBtn').click();"
);
}
}
});
i hope you will find it helpful.
webview 监听及获取cookie的更多相关文章
- Hibernate数据连接不能正常释放的原因,以及在监听中获取apolicationContext上下文
Hibernate数据库连接不能正常释放: https://blog.csdn.net/u011644423/article/details/44267301 监听中获取applicationCont ...
- datePicker 及 timePicker 监听事件 获取用户选择 年月日分秒信息
public class MainActivity extends AppCompatActivity { private TimePicker timePicker; private DatePic ...
- Jquery中input:type=radio的监听,获取设置值
一.html <div id='demo'> <input type='radio' name='sex' value='男' > <input type='radio' ...
- Android中监听webview监听是否加载完成
之前写过一篇捕获Phoengap的webview事件的方法,主要是在实现了CordovaInterface的Activity中, 在onMessage中根据第一个参数的message name来判断 ...
- BroadcoastReceiver之短信到来监听和获取内容
废话就不说了,新建类继承,然后配置Manifest.xml:如下 <!--需要给一个接收短信的权限 --> <uses-permission android:name="a ...
- WebView使用_WebView监听网页下载_DownloadManager使用
最近在做一个较简单的项目:通过一个webview来显示一个网页的App 这个网页有下载的功能,关于这一功能需要用到两个知识点: 1.webview监听网页的下载链接.(webview默认情况下是没有开 ...
- java事件监听
获取事件监听需要获取实现ActionListener接口的方法, public class SimpleEvent extends JFrame{ private JButton jb=new ...
- OC - 18.监听iPhone的网络状态
使用系统的方法来监听网络状态 系统的方法是通过通知机制来实现网络状态的监听 实现网络状态监听的步骤 定义Reachability类型的成员变量来保存网络的状态 @property (nonatomic ...
- 内容观察者 ContentObserver 监听短信、通话记录数据库 挂断来电
Activity public class MainActivity extends ListActivity { private TextView tv_info; private ...
随机推荐
- Holt-Winters
https://blog.csdn.net/u010665216/article/details/78051192 mark
- 【转】tars源码漫谈第1篇------tc_loki.h (牛逼哄哄的loki库)
loki库是C++模板大牛Andrei写的, 里面大量运用模板的特性, 而tc_loki.h借用了loki库的部分代码, 形成了一个基本的文件tc_loki.h, 来看看: #ifndef __TC_ ...
- Python+Selenium+PageObject
一.安装page_objects测试库 二.目录介绍 1.pages包:用于各界面元素定位,如BaseLoginPage.py 2.testcases包:用于编写各功能测试用例,如Login.py 3 ...
- 《Redis 使用规范》
一:Redis 概述 - Redis 是内存级别的数据库,在一台普通电脑上,Redis 3.X 便可以读取 10 万个键值对(现在的Redis官方版本已经更新到了5.X,性能会更好). 二:关于Red ...
- new和malloc区别,delete和delete []区别
面试被问到上述问题,所以特地总结一下: 一.new和malloc的区别. 1.new可以返回指定类型的指针,并且自动分配内存大小:malloc需要计算手动计算分配空间的大小,并且返回值需要强转为实际类 ...
- 洛谷P4456 交错序列[CQOI2018] dp+数论
正解:dp 解题报告: 传送门 首先可以先拆下这个贡献式,为了方便之后设状态什么的,把式子转成和ny有关,就成了 \(\sum \left ( n-i \right )^{a}\cdot i^{b}\ ...
- Cutting Codeforces Round #493 (Div. 2)
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...
- 【LeetCode每天一题】Rotate List(旋转链表)
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: I ...
- CJSON parse.c
#include <stdio.h> #include <stdlib.h> #include "cJSON.h" void printJson(cJSON ...
- JavaScript实现RSA加解密
在GitHub上找到jsencrypt.js对RSA加解密的工具文件,地址分别是:https://github.com/travist/jsencrypt和https://github.com/ope ...