Is it possible to force iphone/ipod to update apple-touch-icon once webapp is added to home screen?

TKTS picture TKTS · Jan 3, 2011 · Viewed 13.6k times · Source

I have created a webapp using all of the recommended link and meta tags for safari, eg.

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-startup-image" href="/startup.png" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> 
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-ipad.png" /> 
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-iphone4.png" />

However, my issue is if the startup.png or any of the apple-touch-icon image files are updated on the webserver, it doesn't seem like a user's iphone or ipod will retreive the updated file once it has been saved to their home screen (I'm guessing it's cached somehow or something). It works to remove the webapp from the home screen and re-add it. But is there a way to let the application know it needs to refresh these images without requiring the user to delete and re-add it?

Answer

Michael Irigoyen picture Michael Irigoyen · Jan 3, 2011

It's been a few years since this question was asked/answered and I'm here to report that this is now possible!

In newer iterations of iOS, the Apple Touch Icon that is displayed on the homescreen is cached just like any other piece of content from the website. By simply changing the name of the image, it will force the homescreen shortcut to refresh the icon the next time the shortcut is launched.

However, to keep in line with Apple's naming conventions, you can simply append URL variables to the reference whenever you want the icon to be redownloaded and continue to call the image apple-touch-icon.png.

What I have done to automate this issue (in PHP) is append the last modified date/time to the image. For example:

<link rel="apple-touch-icon" href="apple-touch-icon.png?m=<?php echo filemtime('apple-touch-icon.png'); ?>" />

This outputs:

<link rel="apple-touch-icon" href="apple-touch-icon.png?m=1415832495" />

Now, you don't have to do anything but literally overwrite the image and everything else will happen automatically. When you change the image, the modified time changes and doesn't match what the user has in cache anymore, so it forces a new download. Simple!


OLD ANSWER: I've done a ton of research into this trying to find a way. Unfortunately, it is not possible. It needs to be removed and re-added to the home screen for the new icon to be used.