簡體   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