如何使用WKWebView执行清单请求 [英] how can I do manifest request with WKWebView

查看:133
本文介绍了如何使用WKWebView执行清单请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的应用中使用新的WebView,但似乎
WKWebView 无法与 NSURLCache <一起使用/ code>和 Manifest 请求不起作用,没有加载请求,也没有存储任何内容。

I was trying to use the new WebView in my app, but it seems that WKWebView can't work with NSURLCache, and Manifest request didn't work, no request was loaded and also nothing was stored.

除了使用 NSURLCache <之外,使用 WKWebView 代替 UIWebView ,一切似乎都能更好地工作/ code>和 Manifest ,所以我想知道是否有办法解决这个问题。

Everything seems to work better using WKWebView instead of UIWebView except for using NSURLCache and Manifest, so I wonder if there are some ways to solve this matter.

PS我已经尝试了私有API _setOfflineApplicationCacheIsEnabled:并且它确实有效,但使用非公共API的应用程序将被苹果拒绝...我现在已经没想到了。

P.S. I've tried Private API _setOfflineApplicationCacheIsEnabled: and it does work, but app using non-public API will be rejected by apple... I'm now out of ideas.

推荐答案

目前,WKWebView实例将忽略任何默认网络存储(NSURLCache,NSHTTPCookieStorage,NSCredentialStorage)以及标准网络类您可以使用自定义网络请求(NSURLProtocol等)。

Right now, WKWebView instances will ignore any of the default networking storages (NSURLCache, NSHTTPCookieStorage, NSCredentialStorage) and also the standard networking classes you can use to customize the network requests (NSURLProtocol, etc.).

因此,WKWebView实例的cookie不会存储在应用程序的标准Cookie存储中,并且所以只使用标准Cookie存储的NSURLSession / NSURLConnection无法访问WKWebView的cookie(确切地说,这可能是你遇到的问题:登录状态很可能存储在cookie中,但是NSURLSession / NSURLConnection不会看到cookie)。

So the cookies of the WKWebView instance are not stored in the standard Cookie storage of your App, and so NSURLSession/NSURLConnection which only uses the standard Cookie storage has no access to the cookies of WKWebView (and exactly this is probably the problem you have: the „login status" is most likely stored in a cookie, but NSURLSession/NSURLConnection won’t see the cookie).

缓存,凭证等情况也是如此.WKWebView有自己的私有存储空间因此不能很好地使用标准的Cocoa网络类。

The same is the case for the cache, for the credentials etc. WKWebView has its own private storages and therefore does not play well with the standard Cocoa networking classes.

您也无法自定义请求(添加自己的自定义HTTP标头,修改现有标头等) ,使用您自己的自定义URL方案等,因为WKWebView也不支持NSURLProtocol。

You also can’t customize the requests (add your own custom HTTP headers, modify existing headers, etc), use your own custom URL schemes etc, because also NSURLProtocol is not supported by WKWebView.

所以现在WKWebView对很多应用程序来说都没用,因为它不参与Cocoa的标准网络API。

So right now WKWebView is pretty useless for many Apps, because it does not participate with the standard networking APIs of Cocoa.

这篇关于如何使用WKWebView执行清单请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆