问题
I developed a few appllications with google app script and deployed them as Web apps they are all working fine.Then I decided to convert them to PWA's.The reason was to make them installable on smart phone User's Home Screen, being able to use push notifications, cacheing e.t.c. (All the advantages that PWA's offer in short.)
I started learning about PWA's. As a result I came to a conclusion that I need a maifest.json file that browsers dowload , a service-worker.js that again browswers download and run.
Unfortunately, app script development environment does not allow to add files with *.json and *.js extensions.
So, does that mean I can't convert my google app script web apps to PWA's?
Thank you.
回答1:
A theoretical solution would be include the files inline, somehow like this for the manifest (taken from this answer)
<link rel="manifest" href='data:application/manifest+json,{ "name": "theName", "short_name": "shortName", "description": "theDescription"}' />
and for the service workers just including directly the tag; but service workers must be by nature independent from the page (see here).
So we could try to serve them through doGet(e). BUT unfortunately is not possible at current time, since you'd need to foreign fetch the service worker, but Foreign Fetch has been removed from Service Workers see this other reply for more details
回答2:
Correct
Your PWA needs to be able to register a service worker to be installed
Once you have something like that, use the Lighthouse Audit tool to test your PWA
That is available in the Chrome Dev tools or as a Chrome Extension
Under the PWA results you should see
---- "User can be prompted to Install the Web App"
If you want to try a working example with the audit tool, I have one here
https://a2hs.glitch.me/
That is a test PWA
I intercept the Chrome & Edge A2HS prompts
And show a button for the user to install if/when they like
来源:https://stackoverflow.com/questions/51458858/how-to-develop-progressive-web-app-with-google-app-script