Does removeCachedResponseForRequest work. I am trying to clear cache of uiwebview.
Any alternative of removeCachedResponseForRequest except removeAllCachedResponses that can be used to achieve clearing cache of a webview.
Related
I have an iOS webview app which require access to third party cookies accessed from inside an iFrame, even if I clear the Prevent Cross Site Tracking on IPhone Safari Settings, it does not work!
But when I access the webview link directly using Safari (Desktop) and clear the Prevent Cross-Site Tracking, it works fine!
I have been trying for over a week now, and no luck
I have added NSCrossWebsiteTrackingUsageDescription to the info.plist on the iOS app and I can see the new settings for the app, but even if I allow cross-site tracking, still does not work!
I have also added WKAppBoundDomains to the info.plist as an array with different combination as below:
thirdparty.com
*.thirdparty.com
a.thirdparty.com
a.b.thirdparty.com
with no luck either!
I have been searching SO, Apple Forum and webkit for many days, seems some people have it working but i have no clue how did they get it to work as there were no clear solutions?
I am not sure why Safari (Desktop) behaves in a different manner to Safari (Mobile)!
I have tried on simulator and an iphone device, cleared all data and website cookies, still not working.
If you have successfully implemented WkAppBoundDomains or NSCrossWebsiteTrackingUsageDescription, please share your solution as I am out of ideas.
Your time is greatly appreciated
Xcode: 12, iOS: 14
I have a React Native application that uses a WebView to display a Highcharts chart. It was working for a while but out of nowhere it just stopped loading in Android. The only fix I could find was to disable Chrome and re-enable it. Which makes me believe there is something going on Chrome on my phone that's making it break. I see in the Android developer docs, the WebView has a destroy() function.
Is there a way I can call this function from my React Native app?
MMM the purpose of the question is unclear.
You don't want to display the webview ? don't display it , remove it from the render function.
You want to display the webview ? display it.
You want to have conditional rendering ? have it, it will destroy the webview or create a new one. There is a lot of posts of how to have conditional renderind in google.
My suggestion would be... update chrome. If it's already updated, go back to previous versions. If you have android 7+ i think you can change the webview provider in the developer options, if you can, change it to android system webview (you will need to manually install it from the play store). Don't use a native solution for personal device problems.
I am aware that offline application cache is not supported in iOS WKWebView.
This is enabled in Safari, so I searched webkit project for the responsible code & found this
WKPreferences
- (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled;
Anyone familiar with this method? is it possible to enable app cache in iOS by accessing this private methods? (I am not going to ship the app to Appstore)
Update 2022
According to one of the comments below, this hack doesn't work anymore.
Yes, we can enable App cache by accessing private API
Create a category for WKPreferences and add to following method signature.
#interface WKPreferences (MyPreferences)
- (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled;
#end
(I tried performSelector:withObject: but it didn't work. No idea why)
After initializing the WKWebView, enable the appcache by calling the above method in the following object
[_wkWebView.configuration.preferences _setOfflineApplicationCacheIsEnabled:YES];
It will create the ApplicationCache.db file in the Cache directory and allow the web app to work offline.
Warning :
2.5. Apps that use non-public APIs will be rejected
According to this tweet from at Apple, as of iOS 10, App Cache is now supported in WKWebView:
https://twitter.com/andersca/status/743259582252879872
...as does this WebKit bug report:
https://bugs.webkit.org/show_bug.cgi?id=152490
I've tested this in WKWebView using this site:
http://webdbg.com/test/appcache/
and can confirm it works as expected both in the iOS Simulator and on devices running iOS 10.
I've been trying for a while to make my HTML5 cache manifest work with phonegap on iOS devices, but I can't get it working (it does work with the pure web version of the app though).
Has anyone have used it successfully?
(I've only founded two people saying that it has worked (1, 2), but I'm searching for more feedback)
Try having a look at this article
http://tmkmobile.wordpress.com/2012/03/04/html5-offline-solution/
I haven't worked in iOS myself but by the sound of it, as long you have correctly setup your cache spec, it should just work on iOS. Only Android needs a little extra work.
I'm having a very strange issue with my web app (which is ran in full-screen mode from the home screen) and Mobile Safari. Usually, as I develop, I edit the files with the changes that I want to make and then I re-launch the app from the homescreen. As per iOS design, the web app will refresh and reload the site.
However, in some odd but frequent situations, when I launch the application I get a cached older version of the app. If I navigate to the app through Mobile Safari (not from home screen) then everything looks great.
I've added meta no cache tags all over the space and even attempted to thwart the cache by adding ?query strings to .css files, etc, but for some odd reason when a cached version decides it wants to display - it will display, no matter what. Clearing cache and data from the settings menu and then relaunching will only sometimes fix the problem.
Anyone else run into this issue? If so, how did you fix it? Is it a known iOS bug? I'm thinking about adding some onLoad code to check if the application is running in full screen mode and then explicitly force a refresh.
Please help - this is extremely annoying and frustrating!
Rich
In my own testing I also found that applications run from the "Home Screen" on iOS won't properly refresh their CSS and JS files. This appears to be an ongoing problem. The only solution that worked for me was to:
Change the device date forward by 2 days or so..
Reload the app from the Home Screen..
Reset the date.
I also tried deleting and recreating the icon from the home screen and clearing the cache in Safari.
"Happily" you are not the only one seeing this problem.
https://discussions.apple.com/thread/3385843?start=90&tstart=0
Incase anyone asks. There were no manifest files involved in my testing.
iPad 2 with IOS 5.1.1.
Enable Debug console from "Settings>Safari>advance" and see if you've any errors there.
Most probably you may have an 'Invalid MIME type", Manifest Parsing or Resource Fetch Failure Error.
Fix them (this link might help in fixing those http://www.fuckyeahtml5.com/2011/06/debugging-html5s-offline-web-apps/).