<legend id='IS835'><style id='IS835'><dir id='IS835'><q id='IS835'></q></dir></style></legend>
    <tfoot id='IS835'></tfoot>
  1. <small id='IS835'></small><noframes id='IS835'>

        <bdo id='IS835'></bdo><ul id='IS835'></ul>

    1. <i id='IS835'><tr id='IS835'><dt id='IS835'><q id='IS835'><span id='IS835'><b id='IS835'><form id='IS835'><ins id='IS835'></ins><ul id='IS835'></ul><sub id='IS835'></sub></form><legend id='IS835'></legend><bdo id='IS835'><pre id='IS835'><center id='IS835'></center></pre></bdo></b><th id='IS835'></th></span></q></dt></tr></i><div id='IS835'><tfoot id='IS835'></tfoot><dl id='IS835'><fieldset id='IS835'></fieldset></dl></div>
    2. 如何使用 UIWebview 删除 iOS 应用程序的 html5 本地存储

      时间:2023-10-22

      <legend id='2bDLd'><style id='2bDLd'><dir id='2bDLd'><q id='2bDLd'></q></dir></style></legend>
      <i id='2bDLd'><tr id='2bDLd'><dt id='2bDLd'><q id='2bDLd'><span id='2bDLd'><b id='2bDLd'><form id='2bDLd'><ins id='2bDLd'></ins><ul id='2bDLd'></ul><sub id='2bDLd'></sub></form><legend id='2bDLd'></legend><bdo id='2bDLd'><pre id='2bDLd'><center id='2bDLd'></center></pre></bdo></b><th id='2bDLd'></th></span></q></dt></tr></i><div id='2bDLd'><tfoot id='2bDLd'></tfoot><dl id='2bDLd'><fieldset id='2bDLd'></fieldset></dl></div>
    3. <tfoot id='2bDLd'></tfoot>
        <bdo id='2bDLd'></bdo><ul id='2bDLd'></ul>
              <tbody id='2bDLd'></tbody>

          • <small id='2bDLd'></small><noframes id='2bDLd'>

              1. 本文介绍了如何使用 UIWebview 删除 iOS 应用程序的 html5 本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I have an app that uses UIWebview which is used to browser different sites/urls. I am in need of an option "clear client data" similar to iOS mobile safari "Remove All website Data" that removes cookies/local storage. I know how to do the cookies but i am unable to figure out how to remove/clear the later (local storage)

                How to remove HTML5 persistant databases in UIWebView? discussed this but i didn't see how that works for my above case. localStorage.clear() javascript needs to be run in UIWebview stringByEvaluatingJavaScriptFromString() method but this didn't seem to have worked in my testing. The other concern with the above approach is that, localStorage is url/site specific - but i want to clear all the contents inside localStorage.

                Tried removing/copying Appln/Library/WebKit/LocalStorage folder - but this didnt work out with access restriction errors.

                Any suggestions/directions please ?

                解决方案

                You should be able to do it cleaning the content of the Caches directory of your app:

                EDIT: Update code as suggested by @RaphaelSchweikert because of wrong error management.

                // first, remove the cookies. 
                NSHTTPCookie *cookie;
                NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
                for (cookie in [storage cookies]) {
                    [storage deleteCookie:cookie];
                }
                
                NSString *path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
                NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
                for (NSString *string in array) {
                    NSLog(@"Removing %@", [path stringByAppendingPathComponent:string]);
                if ([[string pathExtension] isEqualToString:@"localstorage"])
                    [[NSFileManager defaultManager] removeItemAtPath:[path stringByAppendingPathComponent:string] error:nil];
                }
                

                Inside that folder on my simulator I see many .localstorage files ;-) Try and let me know

                这篇关于如何使用 UIWebview 删除 iOS 应用程序的 html5 本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 UIWebView 中检测下载 下一篇:如何使用 Javascript 与 Objective-c 代码进行通信?

                相关文章

              2. <small id='YePlv'></small><noframes id='YePlv'>

                    <bdo id='YePlv'></bdo><ul id='YePlv'></ul>

                1. <i id='YePlv'><tr id='YePlv'><dt id='YePlv'><q id='YePlv'><span id='YePlv'><b id='YePlv'><form id='YePlv'><ins id='YePlv'></ins><ul id='YePlv'></ul><sub id='YePlv'></sub></form><legend id='YePlv'></legend><bdo id='YePlv'><pre id='YePlv'><center id='YePlv'></center></pre></bdo></b><th id='YePlv'></th></span></q></dt></tr></i><div id='YePlv'><tfoot id='YePlv'></tfoot><dl id='YePlv'><fieldset id='YePlv'></fieldset></dl></div>
                  1. <tfoot id='YePlv'></tfoot>
                    <legend id='YePlv'><style id='YePlv'><dir id='YePlv'><q id='YePlv'></q></dir></style></legend>