繁体   English   中英

有没有办法从 Xamarin ios 中的 web 视图中清除缓存?

[英]Is there any way to clear cache from web view in Xamarin ios?

我使用 embedio(外部包)开发了一个混合 xamarin ios 移动应用程序。 我在 ios 项目资源下添加了前端资源文件(html 和 javascript 文件)。 然后我们使用资源文件夹中的 embedio 运行 static 文件服务器。 web 视图正在从嵌入式服务器加载内容。

我还从应用程序内部实现了应用程序内更新。 我们通过从应用程序打开外部 url 来更新我们的应用程序。 例如:itms-services://?action=download-manifest;url= https://demo-application/download/1.0.1/plist

ios 然后开始更新,因为应用程序包 ID 和更新 plist 包 ID 相同。

问题是 web 视图 html 内容未更新。

但是如果我直接安装最新版本,那么 web 视图会加载更新的内容。

我已经厌倦了将 static 文件服务器的位置从捆绑资源更改为 Environment.SpecialFolder.Personal,并且我在资源文件夹中添加了特定于版本的 html 内容。 还尝试通过清除 web 视图的 cookies 来尝试。

//嵌入式服务器

var staticFilesWebServer = new WebServer(XamarinConstants.XamarinConstants.FrontEndServerUrl);
                staticFilesWebServer.RegisterModule(new StaticFilesModule(location));
                staticFilesWebServer.Module<StaticFilesModule>().UseRamCache = true;
                staticFilesWebServer.Module<StaticFilesModule>().DefaultExtension = ".html";
                staticFilesWebServer.Module<StaticFilesModule>().UseGzip = false;

// main page where i have the web view 
WebView.BaseUrl = XamarinConstants.XamarinConstants.FrontEndServerUrl;
WebView.Source = XamarinConstants.XamarinConstants.FrontEndServerUrl + url;
//url for deepli`enter code here`nk 
WebView.ContentType = WebViewContentType.Internet;

web 视图应加载更新的 html 内容。

这应该为您解决问题:

NSHttpCookieStorage CookieStorage = NSHttpCookieStorage.SharedStorage;

        foreach (var cookie in CookieStorage.Cookies)
            CookieStorage.DeleteCookie(cookie);

链接在此处提供更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM