PWA does not work offline only on iPadOS if the Service Worker has a redundant "if (false) {} " in it - progressive-web-apps

I have a Progressive Web App (PWA) that does not work offline on iPadOS if the Service Worker has a redundant "if (false) {} " in it.
To demonstrate the problem, I have set up 2 websites;
https://pwadoeswork.azurewebsites.net/ (this one does work offline) and
https://pwadoesnotwork.azurewebsites.net/ (this one does not work offline)
These differ only in the service worker. The one that does not work has the following entirely redundant code at the top...
if (false)
{
self.addEventListener('fetch', () => { });
}
else
{
:
:
}
The "(false)" is generated by server-side code (Razor .net core) and it is true when running in Dev and false on Production (inspired in part by the Visual Studio Blazor PWA template when you create a new project)
The PWA installs and works offline on the PC, Android (phone, tablet with either Chrome or Samsung Internet) and iOS (mobile phone) precisely as expected. However, only on iPadOS (at least v15 & v16), after you have installed the PWA (Safari->Share->Add to Home Screen->Add) and run it, and then close it (multi-finger pinch and swipe the app off) and go to Aeroplane mode, and then run it from the Home Screen again, Safari reports that it is offline. If you do the same process with the version that does work (without the redundant code) then it runs offline as expected.
The only difference is the "if(false) {} " code. Needless to say, this should not impact anything.
Some questions;
Am I missing something here?
Is this just an iPadOS/Safari bug?
Does the iPadOS run some cut-down version of the javascript engine when running the service worker?
Are there any other hidden gotchas or limitations that I should be aware of that only impact iPadOS with PWA?
Is this behaviour documented somewhere?
DJA

Related

selectChannel command is not working on the Google Assistant

I'm trying to add a select channel trait.
what I did was that I followed the docs,
1- Add the ATTRIBUTES to the device I want to apply this feature on, for example, a TV device type
2- I guess we are all done as every other command works with my code
What I actually did was the following to the device database in Firestore
then added the
case "action.devices.commands.selectChannel":
in the
switch (execution.command) {}
code
then reloaded the device from the google home app
then when I try to call
"Change to ABC on my TV"
it says
'Sorry, I don't understand.'
and nothing appears on the logs
otherwise, everything is working perfectly,i.e setting the volume and On/Off.
what am I doing wrong, please?
UPDATE:
Today I tried command "action.devices.commands.returnChannel" and "action.devices.commands.relativeChannel" and they are working fine
and all three commands belongs to the same trait!
I've seen a lot of users complaining about this command on many sites
like the following 1,2,
could this be related,
I'm still in debug mode, would it be fixed when I publish my app
UPDATE #2
I tried it today with an android phone and it works fine with selectChannel command,
previously I was testing with an iPhone with google home and google assistant apps on their latest release, and the selectChannel is the only command that didn't work there.
Hope it's just related to the debugging mode
It is usually unexpected to have a trait / feature working on the Google Home App on Android but not on the iOS version, as their functionality is nearly identical. The accuracy on the speech to text conversion on both platforms might be different, which could be affecting the functionality. You can try out typing your request to see if that helps in any way.

Why isn't my Chrome App in kiosk mode automatically updating?

I have a Chrome app that runs on a few dozen devices in auto-boot kiosk mode.
I've pushed several updates to the web store, and while I do see the update on my local Chromebox after a little bit of waiting, I've come to learn that the many devices running it in kiosk mode are on an array of older versions. Some seem to have updated at some point in time, but many have not, and none are on the latest version that's already several days old.
Is this because they are in kiosk mode? I found this question over on the product forums, but it has no answer. Seems like the behavior I'm experiencing, and if so I could see why this is the case. Still, all of the documentation from Google pertaining to apps suggests they should always be auto-updating themselves.
We had this same issue and luckily have a support agreement with Google. After some log searching, we were able to determine that the kiosk app we were deploying was specifying a kiosk required_platform_version, eg.
"kiosk": {
"required_platform_version": "11021.56.0"
},
While our Chrome devices (ASUS Chromebit in this case) were already beyond the required version specified. As Chrome won't downgrade itself, the new version in the Chrome Web Store is deemed ineligible for this device and upgrades are never applied.
To resolve this issue, we posted a new version of our Kiosk app with this value updated to match the currently highest deployed Chrome platform version in our fleet (you could also just remove it - but for long running Kiosk apps it's best practice to lock the Chrome version).
Hope that helps!
You may want to check this thread which states the following:
If these are school managed chromebooks, see this topic.
If it is not managed or if the settings have not been changed in the management console, the chromebook does have to be restarted to finish updating.
https://support.google.com/chromebook/answer/3134673?hl=en
Simply follow the given steps on how to manage kiosk settings.

Developing a google play app with HTC Desire

I've been a Java developer for 6 years, but this is my first foray into Android, and it's not going well.
I've set up a simple example app which uses google maps api v2 - it's just a single page: I copied it from one of the many helpful sites on this topic.
I then discovered that I can't run it in an emulator since it uses the google maps api v2, which requires google play. So I bought a device (HTC Desire).
Now the device doesn't show up in the eclipse run configuration. It shows up with ./adb devices just fine.
I thought maybe this was because the device is on Android 2.2, and my app has minimum OS level of 4.2. So I tried to upgrade, but I couldn't work out how. In the software / update section on the phone it just says 'no updates available'. Can this be right?
Ok so assuming I can't upgrade the OS (in which case the phone is now useless), I modified the project so the minSdkVersion is now 8. But now my project won't build!
Errors include 'No resource identifier found for attribute 'showAsAction' in package 'android'' - what does that even mean?
And to cap it all the device is now doing the 'buzzing 7 times instead of booting' thing. I can access some menu called HBOOT, and selecting RECOVERY just reboots the machine, which fails.
So now I've spent £50 and several hours, and I haven't even got as far as hello world - just a bricked phone.
What am I doing wrong? Can Android dev really be this hard?

Adding a NETWORK section to HTML5 manifest file and accessing iPhone web-app in airplane mode

The facts
I'm building an HTML 5 responsive website with an offline mode. To do that, I'm using a manifest file with a FALLBACK section and the browser's localStorage to store the pages that the users decide to save for offline access.
Everything is working great both on desktop or iPhone (haven't tested it on Android yet), except when I add a NETWORK section to the manifest file.
Why do I need the NETWORK section ? I need it for Google Analytics to work - otherwise my website's users won't get tracked, even if the user if online (that's how HTML5 applicationCache works). So this really is mandatory.
On the desktop, this is not an issue, I can turn off the Internet connection and the website works in offline mode.
On the iPhone, however, if i'm turning off the Internet connection (for instance turning on airplane mode) I'm not able to start the web-app (meaning my website added to the home screen) once the NETWORK section is added to the manifest : i'm prompted by iOS to turn on the Internet connection, and the app is closing. If there's no NETWORK section in the manifest file, everything runs fine.
My question
is twofold :
1) while I can understand that there is some logic behind such behaviour, it seems very strange (well, almost unbelievable) to me that you can't have an iOS web-app working in offline mode if there is the slightest attempt to access the network - I've read numerous tutorials about applicationCache on iOS and no one ever mention the NETWORK section's incompatibility with airplane mode.
So, does anyone can confirm (or infirm) what I'm experiencing ?
2) If there is indeed such incompatibility, the only workaround I can imagine is having a dynamically build manifest file server-side, adding a NETWORK section for desktop users only - but that means forgetting about tracking mobile online users, which is not acceptable.
So, does anyone have a better idea ?
Oops, I should have looked better on SO : this has already been answered here :
https://stackoverflow.com/a/6285955/2251905
Following the steps outlined in the abover answer solved the problem.
This has nothing to do with the NETWORK section (thankfully and rightfully !), but with what seems to be an annoying iOS bug on the iPhone.

cordova/phonegap 1.6 crash at second launch

i use xcode 4.3.2 with phonegap 1.6. my app runs well the first time, but if i close the app in the ios simulator and i launch it for the second time, it crashes. Why?
This is probably only in the simulator. I have had it a couple of times in the simulator but it never happened to me on-device.
I am currently having this issue, except in Android. This is with the release flag. More info can be found here: https://forum.ionicframework.com/t/v2-android-second-app-start-doesnt-work-for-release-version/125583
but here is a copy pasta in case the link goes down:
Synopsis:
My app has a canvas on it on the page html. On second start of initial install, app start doesn’t show canvas. I know because the body tag has a background and the canvas has a different background. The page does not have a module defined for it. This is only when built with --release
Environment:
Ionic: 3.20
Cordova: 7.1.0
Angular: 5.2.9
Android: 6.1.2 (I think build target 25)
jdk: 1.8
Additional Info:
I am sort of doing bleeding edge stuff, but I am now out of the realm of being able to solve this on my own. I am using pixi.js, specifically from an additional interface library called angular2pixi. A2p doesn’t support --aot building.
Before I go on, let me reiterate everything works, even on multiple app restarts for everything other than --release.
The top level architecture is fairly simple:
a2p provides a service that has an instance of pixi. My app uses that service and has a page with a canvas awaiting Pixi’s rendering. When the app initializes, it starts up the pixi service, passing it the canvas reference and voila: html5ified angular.
I have offloaded the actual initialization of the rendering to a user clicked button to make sure it’s not something to do with life cycles but that didn’t work either. Even more interestingly, the button I made didn’t show when the app didn’t load. So likely, this means the ion-content itself isn’t showing!
Most interestingly, if I go into app info and delete storage (not cache) then it works on next app start! I am using localstorage but I attempted removing all mentions of it and no luck. ALSO On second install, or rather what would more technically be an update, the app works on every start after that.
This happens on android and I can’t seem to replicate it in iOS other than the first time I tried. Because it is a release build, it’s difficult to debug. I attempted using Ionic Pro Monitoring to no avail.
So far, my leanings are:
some type of caching causing a bug with the canvas itself
an error that is causing cordova or ionic to terminate
problem with my build process
a2p’s architecture (how could I go about debugging this given I have little knowledge of the underlying mechanics of cordova/ng2 -> native compilation?)
a cordova plugin (perhaps causing one of the above)
So as you can probably tell from my formatting, I’m somewhere between nerd heaven and hell. Such a fascinating problem… but plis halp