Can I detect if my PWA is launched as an app or visited as a website?
问题 If I have a PWA I might want to ask my user to add it to their launcher, but I don't want to ask this if it's actually launched from the launcher. Is there any way to detect this from javascript? 回答1: For android, you should only prompt users to install after receiving a beforeinstallprompt event. This event will only be fired if the PWA has not already been installed. window.addEventListener('beforeinstallprompt', (e) => { e.preventDefault(); deferredPrompt = e; // Update UI notify the user