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 ...
随机推荐
- OSS内文件如何设置为无时间限制的下载链接
OSS内文件如何设置为无时间限制的下载链接 想把一些文件上传到OSS里,把OSS当网盘用,做成分享的下载链接 发现获取的链接都是有时间限制的 有没有取消这个时间限制的功能或者方法 请将object的权 ...
- linux ---docker篇
Docker docker是什么? docker最初是dotCloud公司创始人Solomom Hykes在法国期间发起的一个公司内部项目,它是基于dotCloud公司多年云服务技术的一次革新,并在2 ...
- 学习ActiveMQ(三):发布/订阅模式(topic)演示
1.在这个项目中新增两个java类,主题生产者和主题消费者: 2.和点对点的代码差别并不大,所以将消费者和生产者的分别代码拷入新增的java类中,再修改就好了. appProducerTopic代码: ...
- python基础3 条件判断 if嵌套
if单向判断: stonenumber=6#为宝石数量赋值 if stonenumber>=6: #条件:如果你拥有的宝石数量大于等于6个 print('你拥有了毁灭宇宙的力量') #结果:显示 ...
- Logstash安装介绍
前言 logstash是ELK日志系统中的一部分,主要承担将收集完成日志进行过滤,并且输出到es的职责. logstash本身也可以作为客户端部署到应用系统的服务器上进行日志收集,但是由于资源开销占用 ...
- rapidjson对于json的序列化与反序列化
转载: https://blog.csdn.net/qq849635649/article/details/52678822 #include "rapidjson/stringbuffer ...
- file_get_contents("php://input")的用法
$data = file_get_contents("php://input"); php://input 是个可以访问请求的原始数据的只读流. POST 请求的情况下,最好使用 ...
- 运维自动化之系统部署 PXE(二)
PXE介绍 Preboot Excution Environment 预启动执行环境 Intel公司研发 基于Client/Server的网络模式,支持远程主机通过网络从远端服务器下载映像,并由此支持 ...
- ZIP压缩指定路径
using Common; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Quartz; using Quartz.Impl; us ...
- db2一、查询
1.查询单条数据( fetch 放在最后) select * from x where 1=1 order by id fetch first 1 rows only