Missing serviceworker initialization code in PWA wizard template

I noticed that I had to add the code below (from the online doc) to the project html because it was not included by the PWA wizard.

  <script type="text/javascript">
  if ("serviceWorker" in navigator)
  {
    navigator.serviceWorker.register("serviceworker.js").then(
      function(ARegistration)
      {}).catch(
        function(AErr)
        {
          console.log("TMS WEB Core service worker registration failed", AErr);
        });
  }
</script>

I can only suspect that the PWA flag is not set anymore in your project options

or this line is missing in your project HTML file

<meta $(BodyParameters)/>

as otherwise, this code is added automatically in the main project HTML file in this variable (BodyParameters)

Hmm. I don't have such a flag in Project Options, either in my existing project:


or in a new one created with the PWA wizard:

Furthermore, the structure of my Project Options menu (in Delphi 12.3) appears quite different from yours. How can this be fixed?

My screenshot was settings in 10.2

This is the same in v12.3

PWA should be there.
Check this when you create a new TMS WEB Core PWA app.
If it is not there, something must be broken in your IDE / setup. Try to uninstall TMS WEB Core and reinstall v2.9.1.0

My second screenshot was from a new PWA app! I will try uninstalling and reinstall TMS webcore 2.9.1.0. Thanks for that suggestion.

Oops, I guess you meant "2.9.0.1", which is the latest version I see on the TMS website. I've uninstalled and reinstalled that version and Project Options for a new PWA project still lacks both "PWA" and "WEB Project" entries that you show.

What else should I try?

OTOH, I just tried running the new app created by the PWA wizard and the browser developer tools show its serviceworker as "active", so maybe the initialization code is hidden someplace other than in the main html file??

EDIT: OK, I see that <meta $(BodyParameters)/> magically inserts precisely that initialization. Where is BodyParameters defined?

  1. The latest version of TMS WEB Core is v2.9.1.0
    https://www.tmssoftware.com/site/tmswebcore.asp?s=history

  2. If you look at the HTML of the page in the browser console, you should see the service worker initialization code there <BodyParameters> is used in our toolchain as placeholder for where the service worker initialization code is inserted

  1. I thought that by refreshing https://www.tmssoftware.com/site/default.asp?t=1, which I've been doing periodically, I would see the latest version. But that page persisted in showing 2.9.0.1 this morning until I backed up to the main TMS page and retraced to it.
  2. Yes, I do see that code in the output folder.

Thanks, I'll install 2.9.1.0 now and see if the Project Options display updates to what you're seeing.

Have installed 2.9.1.0. Project Options for a new PWA still does not show the two items that yours does:

I checked this deeper and it is indeed only in special development mode that I'm able to see this here on my machine, but this setting isn't shown in a regular user config.
But the fact that you see all PWA settings means it is recognized as a PWA app. Otherwise, you wouldn't see all other PWA related settings.

Thanks for the update. I was only concerned that my system was incorrectly configured, so it's good to know that what I see in that panel is OK.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.