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 ...
随机推荐
- SQL - 1.区分login、user、schema和role
Login Login 是Server一级的概念,表示登录Server的凭证,比如在Server_A上有一个数据库DA,那么想要访问数据库DA,第一步要做的事情就是先登录到Hosting该数据 ...
- Jquery常用的方法总结
1.关于页面元素的引用通过jquery的$()引用元素包括通过id.class.元素名以及元素的层级关系及dom或者xpath条件等方法,且返回的对象为jquery对象(集合对象),不能直接调用dom ...
- Python: map() and reduce()
map()函数接收两个参数,一个是函数,一个是序列,map将传入的函数依次作用到序列的每个元素,并把结果作为新的list返回. 举例说明,比如我们有一个函数f(x)=x2,要把这个函数作用在一个lis ...
- mysql中各种日期数据类型及其所占用的空间
DATETIME,8字节: DATE,3字节: TIMESTAMP,4字节: YEAR,1字节: TIME,3字节:
- 使用npm 下载 cnpm
在vue终端使用npm 1. 下载安装node.js 在node.js中有集成npm 2. 可以在终端中使用 node -v / npm -v 来查看安装的node/npm 的版本号 使用npm 安装 ...
- python练习题-day19
1.将字符串的时间"2017-10-10 23:40:00"转换为时间戳和时间元组 import time s="2017-10-10 23:40:00" st ...
- zabbix基础服务搭建
监控系统的介绍 性能优化和监控点 1.cpu 调度器 有效的分配cpu的时间片 上下文切换 运行队列 ...
- Tomcat配置Web默认页面
1.在web.xml中配置要加载的首页 <welcome-file-list> <welcome-file>Tiring-room/index.jsp</welcome- ...
- Summary: Calculate average where sum exceed double limits
What is a good solution for calculating an average where the sum of all values exceeds a double's li ...
- /etc/resolv.conf
/etc/resolv.conf它是DNS客户机配置文件,用于设置DNS服务器的IP地址及DNS域名,还包含了主机的域名搜索顺序.该文件是由域名解析 器(resolver,一个根据主机名解析IP地址的 ...