WKWebView的Cookie同步以及缓存

坑一:
WKWebView会忽视默认的网络存储, NSURLCache, NSHTTPCookieStorage, NSCredentialStorage。 目前是这样的,WKWebView有自己的进程,同样也有自己的存储空间用来存储cookie和cache, 其他的网络类如NSURLConnection是无法访问到的。 同时WKWebView发起的资源请求也是不经过NSURLProtocol的,导致无法自定义请求。
wkwebview之间的同步问题,不同webview的sessionid不同,登陆态不同
解决方法:使用同一个WKProcesspool

self.sharedProcessPool = [[WKProcessPool alloc]init];  
webViewConfiguration = [[WKWebViewConfiguration alloc] init];  
WKUserContentController *contentController = [[WKUserContentController alloc] init];  
webViewConfiguration.userContentController = contentController;  
webViewConfiguration.processPool = self.sharedProcessPool;  

官方文档提示(海槟提问过)
The process pool associated with a web view is specified by its web view configuration. Each web view is given its own Web Content process until an implementation-defined process limit is reached; after that, web views with the same process pool end up sharing Web Content processes.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容