I’ve set up the Manifest and sw.js files correctly and validated them.
Where do I actually put this code below in Bubble? On Page Load/On Button press -> Run javascript?
I’m sure I’m close but just can’t figure it out!
Promoting installation #
To indicate your Progressive Web App is installable, and to provide a custom in-app install flow:
- Listen for the
beforeinstallprompt
event.
- Save the
beforeinstallprompt
event, so it can be used to trigger the install flow later.
- Alert the user that your PWA is installable, and provide a button or other element to start the in-app installation flow.
Listen for the beforeinstallprompt
event #
If your Progressive Web App meets the required installation criteria, the browser fires a beforeinstallprompt
event. Save a reference to the event, and update your user interface to indicate that the user can install your PWA. This is highlighted below.
let deferredPrompt;window.addEventListener('beforeinstallprompt', (e) => { // Prevent the mini-infobar from appearing on mobile e.preventDefault(); // Stash the event so it can be triggered later. deferredPrompt = e; // Update UI notify the user they can install the PWA showInstallPromotion();});