How to Dynamically Create Mobile Touch Shortcut Icon for Apple iOS and Android


Say your website has 2 users, each has a different avatar icon.  You want the user to be able to create a mobile touch / shortcut / favorite icon on their Apple iOS / Android device / Desktop.  It isn’t really a bookmark icon.


You need to create the icon of the right sizes and add the following to the head section of the HTML:

<meta name="mobile-web-app-capable" content="yes">
<link href="" rel="apple-touch-icon" sizes="76x76" />
<link href="" rel="apple-touch-icon" sizes="120x120" />
<link href="" rel="apple-touch-icon" sizes="152x152" />
<link href="" rel="shortcut icon" sizes="128x128" />
<link href="" rel="shortcut icon" sizes="196x196" />

Note that you have the flexibility of specifying both the url and image filename.

Here is a sample code for ASP.NET to generate the above <link> HTML:

protected void Page_Init(object sender, EventArgs e)
#region shortcut icons for iOS
AddTouchIcon(76, "apple-touch-icon");
AddTouchIcon(120, "apple-touch-icon");
AddTouchIcon(152, "apple-touch-icon");

#region shortcut icons for Android
AddTouchIcon(128, "shortcut icon");
AddTouchIcon(196, "shortcut icon");

private void AddTouchIcon(int size, string rel)
HtmlLink myHtmlLink = new HtmlLink();

myHtmlLink.Href = string.Format("~/Images/B{0}-{1}x{1}.png", CurrentUser.BranchID, size);
myHtmlLink.Attributes.Add("rel", rel);

switch (size)
case 76:
case 120:
case 128:
case 152:
case 196:
myHtmlLink.Attributes.Add("sizes", string.Format("{0}x{0}", size));


Don’t forget the <meta> tag for Android Chrome.

Of course you need to create and store those different images as well.


Note that creating the shortcut is both OS and browser dependent.  On iOS (iPad and iPhone), I had to use Safari.  I could not get Chrome to do it. 

On Android (Samsung Note 3), we had to use Chrome to create the shortcut to the home page.

On PC desktop, I used Chrome to create a shortcut.  Note that it is NOT the same as bookmark.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s