Spomky-Labs / pwa-bundle

PHP library for generating a full featured PWA manifest
https://pwa.spomky-labs.com
MIT License
28 stars 1 forks source link

Add ability to close/uninstall when installed #195

Open tacman opened 1 week ago

tacman commented 1 week ago

Description

How does one close a PWA when it's installed? Is there a programmatic way to click on a button in the app to uninstall it?

Although full-screen is great for a PWA that's installed on a mobile device, it can be a pain to swipe to get the controls to close it, then to find the app itself and uninstall. I was hoping there was an easier way.

Example

No response

Spomky commented 1 week ago

Closing the application is very simple. As it is a browser window (or tab), window.close(); just works fine. For uninstall process, it is a bit different. There is nothing to do on the browser side. It is all about the system host. I described the process on a dedicated documentation section: https://pwa.spomky-labs.com/how-to-install-remove-a-pwa#removing-a-pwa

tacman commented 1 week ago

Indeed, these are the instructions I was hoping to replace with an uninstall button.

Users will come to a gallery / museum, download the audio-tour, but after they leave they probably don't want it on their device.

--

Android

On an Android device, locate the PWA icon in your app drawer or home screen. Long-press the icon, then select the 'Uninstall' option. Confirm your choice if prompted. This will remove the PWA from your Android device.

Spomky commented 1 week ago

Indeed, this is not possible anymore. On the page I linked above we can read "This method can only be called on windows that were opened by a script using the Window.open()".

Spomky commented 1 week ago

Users will come to a gallery / museum, download the audio-tour, but after they leave they probably don't want it on their device.

I agree. Since users are not expected to come and use the app again and again, the option to install it becomes useless.

tacman commented 1 week ago

Yeah, maybe that should be my approach.

I like the full-screen option, but there's probably a way to do that in plain javascript. As long as it pre-fetches the images and audios (since the gallery doesn't have wifi throughout), it should work as expected.

The images and audios are all on s3, but they're from a database, so I think I need to use a feature you added for exactly that. It's a twig tag, right? I can't use the prefetch using the option in the pwa.yaml (since they come from a database), but I can use Symfony's weblink to create

And then create a resource cache rule to match https://voxitour.s3, right?

Spomky commented 1 week ago

Yeah, maybe that should be my approach.

Yes! The fullscreen API (almost always available)

And then create a resource cache rule to match https://voxitour.s3/, right?

It should work (it does for other resource types such as the ones served by a CDN) but I never experimented it. <link rel="prefetch" href="...."> is really simple. No headache. The @pwa/prefetch-on-demand stimulus controller is another way to acheive that on a button click or any other action. I prefer this way as the user explicitly asks for the data to be downloaded when the link tag is silent.

Instead of an uninstall button, may a "I am done, clear the data" button could be fine. This button would remove the large assets (audios) and keep the core files (CSS, JS, pages...).