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 ...
随机推荐
- Android总结之json解析(FastJson Gson 对比)[申明:来源于网络]
Android总结之json解析(FastJson Gson 对比)[申明:来源于网络] 地址:http://blog.csdn.net/u014031072/article/details/5392 ...
- 在利用node连接数据库遇到的问题
本文持续更新 选择数据库时: connection.query('USE ' + dbName,function(err,rows){ //注意USE后面需要加一个空格,最终才能拼成> USE ...
- checkPathValidity 检查所有agent的corridor的m_path是否有效
在checkPathValidity(检查所有agent的corridor的m_path是否有效) 如果是无效的要进行重新设置并且设置replan 首先获得第一个polygon,m_path[0] 这 ...
- smarty 循环一维关联数组
<?php $oStatusList = array('1'=>'待投放','2'=>'正在运行','3'=>'暂停','4'=>'已完成','5'=>'已删除') ...
- 《Redis 使用规范》
一:Redis 概述 - Redis 是内存级别的数据库,在一台普通电脑上,Redis 3.X 便可以读取 10 万个键值对(现在的Redis官方版本已经更新到了5.X,性能会更好). 二:关于Red ...
- VUE-010-通过声明式导航 router-link 传递 params 参数(路由 name 识别,请求链接不显示参数传递)
在前端页面表单列表修改时,经常需要在页面切换的时候,传递需要修改的表单内容,除了通过路由进行表单参数的传递,也可通过声明式导航 router-link 进行页面跳转和参数传递. 首先,配置页面跳转路由 ...
- 小程序 滚动wx.pageScrollTo
API:https://developers.weixin.qq.com/miniprogram/dev/api/wx.pageScrollTo.html wx.pageScrollTo 在小程序的开 ...
- 486A
#include <stdio.h> int main() { long long ans; long long n; scanf("%I64d", &n); ...
- 3.1.3 Spring之AOP
三.Spring之AOP 1. 代理模式 (1) 什么是代理模式? 代理模式是面向对象编程的23种基础设计模式之一.为其他对象(代理对象)提供一种代理以控制对这个对象(源对象)的访问. 就是说,声明一 ...
- AIX修改密码
grid@DB01:/home/grid>su - oracleoracle's Password: 3004-303 There have been too many unsuccessful ...