How to set up web clip icons in "Google apps script"

70 views Asked by At

I'm building a web app with "Google apps script" and I can't set the web clip icon because some tags in the head are ignored in the GAS html file. setFavioconUrl() allowed me to set the favicon, but I'm having trouble setting the smart phone icon (apple-touch-icon). I also tried to insert an icon later using javascript, but this was also ignored. Is there any way to fix this?

1

There are 1 answers

1
Mahesh Prajapati On

You can set the apple-touch-icon meta tag or any other meta tag dynamically in your GAS web app. Keep in mind that this is a workaround and not a direct solution due to GAS's limitations in directly manipulating HTML head elements.

<head>
  <meta charset="utf-8">
  <title>App Title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- #INSERT_APPLE_TOUCH_ICON# -->
</head>
<body>
  <!-- Your app content goes here -->
</body>

Google Apps Script

function doGet() {
  var template = HtmlService.createTemplateFromFile('templatefile');
  
  // Replace the placeholder with the actual meta tag
  var appleTouchIconTag = '<link rel="apple-touch-icon" href="iconUrl.png">';
  template.appleTouchIconTag = appleTouchIconTag;

  return template.evaluate();
}