iOS6 - How to Clear Cache of Homescreen/Standalone Web App? - ios

It would appear that Apple have changed the way homescreen/standalone web apps work in iOS 6. According to various blog posts (example) these apps now get their own dedicated space for storing their cached files, sqllite dbs, local storage etc, rather than sharing with the Safari browser like before.
Before iOS 6 when developing I used to go through the following procedure religiously to clear the cache...
Remove app from homescreen.
Close all pages/tabs in Safari.
Finally "Clear Cookies & Data" or "Clear Data" in "Settings" > "Safari".
Unfortunately now that Apple have moved the goal posts this same procedure doesn't seem to work. After clearing, even though my changes are picked up in Safari, when I add to the homescreen and launch the app the old HTML,JS etc is still picked up.
Does anyone know how to reliably fully clear the cache in iOS 6?

I can't verify the cache being cleared properly but this worked for me :
In order to do this, you need to allow Web Inspector on your iOS device.
Go to Settings > Safari > Advanced > Web Inspector (it has to be active)
And you have to activate the developer menu on your computer's Safari.
Go to Preferences > Advanced > Activate Developer menu
Connect your device to your computer with the USB cable
Go to safari > Developpement > Your Device name > Inspect an App (The app has to be running)
This will open The inspector on your computer for the web app
While the inspector is open Clear the cache (command + alt + E)
With the inspector still open refresh the page on your computer (command + R)
Somehow the Webapp cache got cleared and i got the non-cached code.

I found a a work-around. Just put a link on the web page itself for users who are having trouble seeing new version...
refresh
It works just like the iPhone/iPad refresh button on the address bar!

First plug the phone into the computer then open the web app on the phone and Safari on the computer, then you can open the web inspector in Safari from the menu "Develop>Name of phone>title of app" (if you can't see the develop menu you can turn it on in Safari's preferences).
From there you can see/edit the cookies and local storage just like sites on your computer and pressing command+r while the inspector is focused will reload the app on the phone.

You can connect your device and open Safari's web inspector on your computer and run document.location.reload() in the console tab to reload the page.
Before reloading you can press Option+Command+E to make sure the cache is cleared.
Instead of above you can also press Shift+Command+R to reload the page without cache but sometimes it hasn't worked for me.

Try appending a unique GET tag to the ends of any and all href attributes, for example:
<link rel="stylesheet" type="text/css" href="/css/global.css?
<?php echo(mt_rand(10000000, 99999999)); ?>
" />
This would generate href="/css/global.css?########", with a different number nearly every time. This forces iOS' Safari to pull the "new" page down, as there is no data in its cache originating from the same URI, and there likely never will be (unless you plan on reloading the app millions of times during development :D )

If the iOS6 device has a jailbreak applied, you can use ssh to delete the content of the folder "/private/var/mobile/Library/Caches/com.apple.webapp".
Next time that you start the web app, all files will be re-downloaded from the webserver.

The only way to deal with this currently is to wait, but there is a workaround. If you change the name of the file, it will pull the new code. However, if you change it back to the old name before the cache clears, the old code will be used. The cache refreshes periodically and will update eventually. I just had this happen to me with a CSS file that refused to change. Time will fix it, but if you just need it to update for testing, a name change will work.

This drove me nuts for a while. Tried clearing the cache on device - no luck. Renaming the page did help, but once you rename it back, you still get the same stale version.
Found the solution yesterday. You need to connect your device to Mac and open Web Inspector in Safari Develop menu. Once in Web Inspector, simply press "Reload page" button on the Inspector's toolbar and - voila - you see the fresh version on your device's screen.

Just set the request you pass to the webview to NSURLRequestReloadIgnoringLocalCacheData
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[self.webView loadRequest:request];

Related

Cordova - Safari iPhone remote inspection disconnects

I'm using the Safari Web Inspector to remote debug a Cordova app I'm building. Previously this has worked like a charm, but now I've run into an issue. After launching the inspector, after a couple of seconds it seems like the web inspector disconnects from the device. The inspector is still open, but the inspector wont update, and elements on the device wont be highlighted anymore when hovered in the inspector (this works for the first couple of seconds). I'm able to get it running for a couple of seconds again by closing the inspector and launching it again.
I've tried debugging using Chrome and ios_webkit_debug_proxy instead, which doesn't disconnect. However, this has other issues which makes it a none viable solution.
I've tried using Safari Technology Preview (11.0 R35) as well as the current stable version of Safari (10.1.2), but the issue occurs in both of them. I've also tried switching the lightning cable and USB-port on my computer, which doesn't make any difference.
I found that the following error is logged (using the Console app) when the inspector seems to disconnect:
RWIServiceLockdownConnection: Disconnecting because we failed to read a message from webinspectord. This could mean almost anything.
This does seem to have something to do with Cordova, since the error doesn't occur when I inspect a regular page Mobile Safari page.
What could cause this, and how do I resolve it?
Try setting a global hotkey:
Go to System Preferences -> Keyboard -> Shortcuts -> App Shortcuts.
Add a hotkey, whatever keys you want (e.g. Cmd + Alt + I) and match that hotkey to your cordova’s main html file (e.g. index.html).
Launch Cordova App.
Open Safari WI & close it.
Re-launch Safari WI with quick hotkey shortcut set above.
Close & re-open cordova app, Safari WI should keep debugging.
Also, as stated in comments, try keeping Xcode open.

Universal links (Deep linking) not working on iPhone but works on iPad

I am trying to build deep linking feature into my app. I did all the necessary set up for deep linking to work like, enabling associated domains in my app, adding apple-app-site-association to the root directory of my server, and I am serving a valid apple-app-site-association over https, I also validated my apple-app-site-association using this tool Validate your apple-app-site-association.
After doing everything right, I tested the deep linking feature on my iPad and it worked as expected. But when I tried to do the same on my iPhone it doesn't work, it always took me to safari. I tried it on 6s device, I reinstalled the app, I cleared Safari website data & cleared the history. Also updated the iPhone & iPad to iOS 9.3.5. The updating the OS didn't change a thing.
iPad still continue to work with deeplink URLs just like it did while it was on 9.3.4. iPhone still opened the link in safari.
Please give me some pointers on how to workaround this issue, I think this might be an apple bug but again I don't understand how it can work on iPad which is running same software as iPhone. Any help or guidelines is much appreciated.
Thanks.
I was able to fix this issue and this is one of the annoying issue that I have come across, because it doesn't say what is going wrong.
Fix: Whenever the iOS opens your link in safari, you need to pull down the webpage in safari and there you'll see a banner saying that, open it in the app. Once you click on that banner your future links will start opening the app instead of opening it in the safari browser.
There was no error whatsoever and there was no indication why the link was getting opened I am pretty sure that, iOS didn't download the apple-app-site-association whenever I installed the app.
Also note that the banner in the webpage will not be visible whenever your link opens up in safari, you need to pull down the webpage and then the banner will become visible and if you click on open in app banner, it will start opening the links in app.
If in future if you select to view the link in safari by clicking on context menu which appears on right hand side of the status bar, which will be saying "Open in [your app name]" in safari, the links in future will open in safari instead of app, and again if the banner open in app isn't visible, you have to pull down the webpage to see that banner.
HTH.
In iOS 13, similar problem of direct links not opening the app instead it open the safari website directly.
Fixed by updated the below safari setting...
Settings > Safari > Request Desktop Website > All websites > Switch Off
I was facing the same issue in iOS 12, on one device the link redirected to my app and on another device it was always redirecting to Safari and pressing the link on the Notes app was only allowing me to open it on Safari.
What I believe happened was that I pasted the URL in the browser and clicked Go, as I thought it would redirect to my app. No matter what I did ( reinstalling the app, restarting the device, ... ) the results were always the same, redirecting to Safari.
What helped me was deleting the cached data for my domain ( Settings -> Safari -> Advanced -> Website Data -> Swipe and delete the data for your domain ).
After that, everything started working.
I believe this is a bug with iOS Simulator,
In my case it was occurred when I entered an invalid address (with multiple spaces) for example:
Valid One: myApp://order/10003101
Invalid One: myApp://order/1003131
It stopped working even with Valid One and the solution was to clear Safari Website Data:
Go to Settings/Safari -> Clear History and Webstie Data
Device: iPhone 12 Pro Max
iOS: 14.5
Xcode: 12.5

Smart app banners do not appear after being closed on iPad with IOS7

In short, my team has a mobile site and an app in the appstore. We have added the meta tag to show the smart app banner. I saw it and everything worked as expected. Problem is, I just closed the banner and now it doesn't reappear. I did the same thing with the Ted.com smart app banner with the same results.
Currently, we're using the iPad with IOS7 and I have read all over that it is a cookie preventing the reappearance of the banner. I have cleared Safari's cache and cookies numerous times, made sure to close safari from memory, run safari in private mode, and I've even rebooted the iPad but those dismissed smart banners still don't reappear. Is there something I'm missing? Most of what I've read about the cookies seem to be specific to IOS6, is there a difference here with IOS7? Anyone have an idea as to how to make these dismissed smart app banners reappear?
This issue is solely iOS 7. In iOS 6 all you had to do was clear the Safari cookies and history. Apple must have changed something in how they store if an app banner has been closed in iOS 6 vs iOS 7. Surprise!
The following steps are what I have determined gets the smart-app banner to appear again, confirmed on a device running iOS 7.0.4:
Settings -> Safari -> Clear history
Settings -> Safari -> Clear cookies and data
Settings -> General -> Reset -> Reset Location & Privacy
Settings -> General -> Reset -> Reset All Settings
Not the cleanest, but it gets the job done.
1.remove app from device
2.Settings -> Safari -> Clear History and Website Data
3.Open the safari and open your website
4.Install the app from store
5.reload website
6.good luck
Also had this problem on both iOS8 and iOS9.
Using the info on this page (thanks!), I found the following solution:
USE AT YOUR OWN RISK!
Tested with iTunes 12.3.1.23 on OSX 10.9.5 with iPhone 5S running iOS 8.4.1
Find the app-id by searching the website's source by searching for "app-id"
Example for www.marktplaats.nl: <meta name="apple-itunes-app" content="app-id=373963365, app-argument=marktplaats://homepage">
Make a "local computer backup" with iTunes
Find your backup (probably in: ~/Library/Application Support/MobileSync/)
Make a copy of your backup just in case (Yes: a backup of a backup :-)
Search backup for the app-id. I used: grep "373963365" -r * in the Backup folder
For my example grep found a "hide banner file" starting with 03f01e41fc5d containing the app-id:
bplist00—Y373963365
Change the app-id number to an app-id number from which you never want to see a smart app banner or just increment the app-id by one and save the file.
Restore the changed backup to your device.
Notes:
Making, copying, searching and restoring a backup takes some time if you have a 16GB backup like me; be patient.
You might find multiple app-ids in the "hide banner file". I don't see why this procedure wouldn't work for changing multiple app-ids
Don't delete the "hide banner file" as this will corrupt your backup.
Incrementing the app-id by one or choosing any other 9 figure random number will hide that "random" smart app banner!
I also successfully did this on a new iPad running iOS 9.0.2
For those who want to go the jailbreak way: I found the file on a jailbroken iPad here:
/var/mobile/Containers/Data/Application/{Safari App ID}/Library/Webkit/StoreBannerTracker.plist
#Apple: why can't we just delete this using Clear History and Website Data ????
There is a way to reset the smart banner behaviour without resetting all preferences. It requires either jailbreaking your iDevice or using an iTunes backup editor such as iExplorer.
Jailbreak method
Navigate to Safari application directory (e.g. using iFile):
/var/mobile/Applications/{Safari App ID}/Library/Webkit
(If you are using iFile, application names can be displayed along side the app id folder names. Enable Preferences -> File Manager -> Application Names)
Delete or rename the file StoreBannerTracker.plist
Backup editor method
Backup your iDevice using iTunes. (Probably best not to encrypt the backup)
Use an iTunes backup editor such as iExplorer to delete StoreBannerTracker.plist. In iExplorer:
Browse Local iTunes Backups -> {Name of your iDevice} -> Backup Explorer -> AppDomain-com.apple.mobilesafari -> Library -> WebKit
Right-click StoreBannerTracker.plist and click Delete
Restore the backup to your iDevice using iTunes
(Disclaimer: I haven't tried this method because I use iExplorer in demo mode, which doesn't allow changes.)
For anyone with iOS14+ (because I don't have any older).
Smart app banner shows up fresh every time you open the webpage from Slack.
Tap on Settings > General > Usage > wait for a while till the list of the apps appear... >
Show all apps > Safari > Website Data > Remove All Website Data.
I've tried this on iOS 7 with iPhone 5s, and it will show the smart banner back.
Cheers.
Try clearing Safari Cookies and Data and it should reappear

Facing Error in running ripple emulator (Chrome extension) for app testing?

When i just enable a html file from my pc to emulate.It just shows :--
"Looks like what we have here is a failure to... emulate
You're seeing this window because it looks like the zombie apocalypse has started.
"It says Hit or fire" ""
http://i.stack.imgur.com/1ABj4.png
It is working few days for me..But now i started opening it i got an error. My Ram is 2Gb and supports full requirements..
Please help me out.
That message means Ripple is waiting for something to finish, and has decided to show a warning rather than hanging. You can CTRL+I to open web inspector and see if there are any console messages that help explain what failed.
You can hit the FIRE button to clear all cached settings. This will reset Ripple to its initial state (Ripple stores all user settings in localStorage - hitting the FIRE button clears this localStorage data). If a cached setting was the reason for the "red screen of death", then you will see the black "welcome to Ripple" screen after hitting the FIRE button.
Otherwise, I'd suggest disabling and re-enabling Ripple.
Finally as a last resort, make sure to update to the latest version of Ripple using the *.crx file available here: https://developer.blackberry.com/html5/download/
if you are trying to access something in your local file system i found the problem
https://github.com/blackberry/Ripple-UI/issues/565
since you're running in the file:/// scheme, you need to get around
the browser's security a little bit. Do the following:
in chrome://chrome/extensions/ make sure the "Allow access to file URLs" is checked for Ripple (might have to go into developer mode to do that, check box on the top right of the page)
quit chrome and restart it with --allow-file-access-from-files flag
doing this resolved the problem for me.
you can check with this page github.com/blackberry/WebWorks-Samples/tree/master/HelloWorld

Anyone experience caching issues with web apps ran in full-screen mode iOS/Mobile Safari?

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/).

Resources