Closed Dobermensch closed 1 day ago
You should check if showInstallPrompt
is true, the install function does nothing if not enabled.
I checked the value of showInstallPrompt
. It is false.
I tried to set it to true
and then use the $pwa.install method. Nothing happened.
Here's a snippet of my code:
const addClicked = async () => {
$pwa.showInstallPrompt = true
await $pwa.install()
}
How do I use the $pwa.install method?
That flag must be set by the browser on before install prompt event listener: the sw must installed and activated and the browser must support the feature. You cannot change browser behavior.
You can check the logic here: https://github.com/vite-pwa/nuxt/blob/main/src/runtime/plugins/pwa.client.ts#L86
So if I understand correctly, since I cannot change the browser behaviour, it means it either works or it doesn't. In my case, since it doesn't work, there's nothing I can do?
bump
If the browser doesn't have that feature we cannot do anything, check: https://caniuse.com/?search=beforeinstallprompt
I'm using this plugin with nuxt. Everything works as expected.
However, I wanted to to create a button for the user to add the PWA to the homescreen so I stumbled upon the $pwa.install method.
I'm calling it on button click but it does nothing.
What is it supposed to do or why isn't it working?
I have client: { installPrompt: true } in pwa object in nuxt.config.