Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showInstallPrompt not being called #130

Open
taylorchance opened this issue Apr 18, 2024 · 1 comment
Open

showInstallPrompt not being called #130

taylorchance opened this issue Apr 18, 2024 · 1 comment

Comments

@taylorchance
Copy link

I was hooking up my install button something like this:

v-if="$pwa && $pwa.showInstallPrompt && !$pwa.needRefresh"

I know the beforeinstallprompt listener can be finicky so I just waited it out. Finally I put the listeners in manually like so:


window.addEventListener('beforeinstallprompt', e => {
  e.preventDefault()
  // Stash the event so it can be triggered later.
  deferredPrompt.value = e
})

window.addEventListener('appinstalled', () => {
  deferredPrompt.value = null
})

const installApp = () => {
  deferredPrompt.value?.prompt()
}```

And the button is showing now.
@jeky1950
Copy link

jeky1950 commented May 14, 2024

Try adding this to your nuxt.config.ts:

export default defineNuxtConfig({
     ...
     pwa: {
        devOptions: {
            enabled: true
        },
        client: {
            installPrompt: true
        },
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants