Is it possible convert a web app into a PWA?

540 views
Skip to first unread message

Jorge Forero

unread,
Oct 5, 2019, 4:17:09 PM10/5/19
to Google Apps Script Community
I'm wondering if there is a way to make a web app installable on smart phone User's home screen? By now, I just need an easy way to user get access to the web app without copying and pasting long addresses with parameters in the cell phone) 

Does any one have tried this? I have read some resources about PWA but nothing specific using google app script (It's not clear how to include the manifest (inline maybe?) or where to put the service worker, etc.) 

Is it possible to convert a web app into a PWA?

Any help would be appreciated.  Thanks in advance for any comment or ideas.

Jorge.

Dimu Designs

unread,
Oct 5, 2019, 4:58:45 PM10/5/19
to Google Apps Script Community
There have been attempts but I don't believe anyone has been successful in deploying a GAS Web App as a PWA. 

Ivan Kutil

unread,
Oct 6, 2019, 10:38:14 AM10/6/19
to Google Apps Script Community
Hi, 

I have not found out how to add service workers into Apps Script.

If you want to deploy Apps Script as Android application (access from homescreen with icon), you can use G Suite management tools. Here is an example: https://www.kutil.org/2019/01/deploy-google-apps-script-web-app-as.html

Ivan

ChiefChippy2

unread,
Oct 6, 2019, 11:38:02 AM10/6/19
to Google Apps Script Community
I found this on MDN ; maybe this can help?  :
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>MDN Example - Embedded worker</title>
<script type="text/js-worker">
  // This script WON'T be parsed by JS engines because its MIME type is text/js-worker.
  var myVar = 'Hello World!';
  // Rest of your worker code goes here.
</script>
<script type="text/javascript">
  // This script WILL be parsed by JS engines because its MIME type is text/javascript.
  function pageLog(sMsg) {
    // Use a fragment: browser will only render/reflow once.
    var oFragm = document.createDocumentFragment();
    oFragm.appendChild(document.createTextNode(sMsg));
    oFragm.appendChild(document.createElement('br'));
    document.querySelector('#logDisplay').appendChild(oFragm);
  }
</script>
<script type="text/js-worker">
  // This script WON'T be parsed by JS engines because its MIME type is text/js-worker.
  onmessage = function(oEvent) {
    postMessage(myVar);
  };
  // Rest of your worker code goes here.
</script>
<script type="text/javascript">
  // This script WILL be parsed by JS engines because its MIME type is text/javascript.

  // In the past...:
  // blob builder existed
  // ...but now we use Blob...:
  var blob = new Blob(Array.prototype.map.call(document.querySelectorAll('script[type=\'text\/js-worker\']'), function (oScript) { return oScript.textContent; }),{type: 'text/javascript'});

  // Creating a new document.worker property containing all our "text/js-worker" scripts.
  document.worker = new Worker(window.URL.createObjectURL(blob));

  document.worker.onmessage = function(oEvent) {
    pageLog('Received: ' + oEvent.data);
  };

  // Start the worker.
  window.onload = function() { document.worker.postMessage(''); };
</script>
</head>
<body><div id="logDisplay"></div></body>
</html>

Martin Hawksey

unread,
Oct 7, 2019, 3:07:08 AM10/7/19
to google-apps-sc...@googlegroups.com
Unfortunately this example is for a Web Worker which is different to a Service Worker which is required by a PWA

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/e1226470-9885-42c8-b194-ab844a40e988%40googlegroups.com.

Sam MHDI

unread,
May 26, 2020, 2:28:25 AM5/26/20
to Google Apps Script Community
Hello,

There is tool you could use to convert your web app into a native mobile app, named: nativator.io

It’s a no-code solution that will allow you to include native features such as: push, geolocation, file upload and publish to Play / App store.

It’s also affordable and fast with live chat support. Try it out.
Https://nativator.io

Cheers,
Sam

Jorge Forero

unread,
May 26, 2020, 10:47:51 AM5/26/20
to google-apps-sc...@googlegroups.com
Hi Sam,

Thank you.  Sure, I will try it out!


Mailtrack Sender notified by
Mailtrack 05/26/20, 09:45:59 AM

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

Marko Kolombo

unread,
Jun 1, 2020, 8:02:18 AM6/1/20
to Google Apps Script Community
Hi Jorge,

to add to the previous answers, I can confirm that at the moment (unfortunately!) it is not possible, because t service workers must be by nature independent from the page (a.k.a. be served in their own file), but HtmlService can only "serve" one file at a time; also service workers must be hosted at the same origin (Protocol + Domain name + Port) of the invoking file, so we cannot host it somewhere else.

The workaround I use to create PWAs is leveraging Github pages: I keep in there all the assets I need (images, library scripts and css, jsons, etc.) and also the service workers. The main page index.html (the one I would usually serve through HtmlService) is instead being updated by a script that first of all evaluates the final result of HtmlService, takes the html with getContent() and then updates the file via UrlFetchApp POST to github .

Jorge Forero

unread,
Jun 1, 2020, 8:40:28 AM6/1/20
to google-apps-sc...@googlegroups.com
Marko,

The workaround sounds good to me.  I will try it for sure!  Thanks a lot for your help.
Greetings,
Jorge.


Mailtrack Sender notified by
Mailtrack 06/01/20, 07:37:55 AM

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages